Skip to content

Commit

Permalink
Add option to disable zero check in scenario
Browse files Browse the repository at this point in the history
Currently, it applies only for Cluster Picking, it will apply
on Zone Picking and Discrete Order Picking too.

When a location becomes empty and the option is active, the user has
to validate that the location is really empty. It doesn't really make
sense for picking types that move pallets, so they would disable it
there.

There is an ongoing discussion whether this option should be on the
picking type or on the shopfloor menu, it is possible that this option
will be moved.
  • Loading branch information
guewen committed Jul 7, 2020
1 parent 9f2d671 commit 74342ea
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
1 change: 1 addition & 0 deletions shopfloor/demo/stock_picking_type_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<field name="code">internal</field>
<field name="show_operations" eval="1" />
<field name="display_completion_info" eval="1" />
<field name="shopfloor_zero_check" eval="1" />
</record>
<record id="picking_type_checkout_demo" model="stock.picking.type">
<field name="name">Checkout</field>
Expand Down
6 changes: 6 additions & 0 deletions shopfloor/models/stock_picking_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ class StockPickingType(models.Model):
shopfloor_menu_ids = fields.Many2many(
comodel_name="shopfloor.menu", string="Shopfloor Menus", readonly=True,
)
shopfloor_zero_check = fields.Boolean(
string="Activate Zero Check",
help="For Shopfloor scenarios using it (Cluster Picking, Zone Picking,"
" Discrete order Picking), the zero check step will be activated when"
" a location becomes empty after a move.",
)
3 changes: 2 additions & 1 deletion shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ def scan_destination_pack(self, picking_batch_id, move_line_id, barcode, quantit
)
move_line.write({"qty_done": quantity, "result_package_id": bin_package.id})

if self._planned_qty_in_location_is_empty(
zero_check = move_line.picking_id.picking_type_id.shopfloor_zero_check
if zero_check and self._planned_qty_in_location_is_empty(
move_line.product_id, move_line.location_id
):
return self._response_for_zero_check(batch, move_line)
Expand Down
39 changes: 38 additions & 1 deletion shopfloor/tests/test_cluster_picking_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,11 @@ def test_scan_destination_pack_quantity_less(self):
# the reserved quantity on the quant must stay the same
self.assertRecordValues(quant, [{"quantity": 40.0, "reserved_quantity": 20.0}])

def test_scan_destination_pack_zero_check(self):
def test_scan_destination_pack_zero_check_activated(self):
"""Location will be emptied, have to go to zero check"""
line = self.one_line_picking.move_line_ids
# ensure we have activated the zero check
self.one_line_picking.picking_type_id.sudo().shopfloor_zero_check = True
# Update the quantity in the location to be equal to the line's
# so when scan_destination_pack sets the qty_done, the planned
# qty should be zero and trigger a zero check
Expand All @@ -542,6 +544,41 @@ def test_scan_destination_pack_zero_check(self):
},
)

def test_scan_destination_pack_zero_check_disabled(self):
"""Location will be emptied, no zero check, continue"""
line = self.one_line_picking.move_line_ids
# ensure we have deactivated the zero check
self.one_line_picking.picking_type_id.sudo().shopfloor_zero_check = False
# Update the quantity in the location to be equal to the line's
# so when scan_destination_pack sets the qty_done, the planned
# qty should be zero and trigger a zero check
self._update_qty_in_location(
line.location_id, line.product_id, line.product_uom_qty
)
response = self.service.dispatch(
"scan_destination_pack",
params={
"picking_batch_id": self.batch.id,
"move_line_id": line.id,
"barcode": self.bin1.name,
"quantity": line.product_uom_qty,
},
)

next_line = self.batch.picking_ids.move_line_ids[1]
# continue to the next one, no zero check
self.assert_response(
response,
next_state="start_line",
data=self._line_data(next_line),
message={
"message_type": "success",
"body": "{} {} put in {}".format(
line.qty_done, line.product_id.display_name, self.bin1.name
),
},
)


class ClusterPickingIsZeroCase(ClusterPickingCommonCase):
"""Tests covering the /is_zero endpoint
Expand Down
12 changes: 9 additions & 3 deletions shopfloor/views/stock_picking_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.view_picking_type_form" />
<field name="arch" type="xml">
<field name="warehouse_id" position="after">
<field name="shopfloor_menu_ids" widget="many2many_tags" />
</field>
<xpath expr="//sheet/group[2]" position="inside">
<group string="Shopfloor" name="shopfloor">
<field name="shopfloor_menu_ids" widget="many2many_tags" />
<field
name="shopfloor_zero_check"
attrs="{'invisible': [('shopfloor_menu_ids', '=', [])]}"
/>
</group>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 74342ea

Please sign in to comment.