diff --git a/shopfloor/demo/stock_picking_type_demo.xml b/shopfloor/demo/stock_picking_type_demo.xml index 09c8042865..c64cf5060d 100644 --- a/shopfloor/demo/stock_picking_type_demo.xml +++ b/shopfloor/demo/stock_picking_type_demo.xml @@ -28,6 +28,7 @@ internal + Checkout diff --git a/shopfloor/models/stock_picking_type.py b/shopfloor/models/stock_picking_type.py index f974b0257a..cbe326fc8d 100644 --- a/shopfloor/models/stock_picking_type.py +++ b/shopfloor/models/stock_picking_type.py @@ -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.", + ) diff --git a/shopfloor/services/cluster_picking.py b/shopfloor/services/cluster_picking.py index 75c849ebc7..88fe45175d 100644 --- a/shopfloor/services/cluster_picking.py +++ b/shopfloor/services/cluster_picking.py @@ -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) diff --git a/shopfloor/tests/test_cluster_picking_scan.py b/shopfloor/tests/test_cluster_picking_scan.py index 11909cccf0..3c097a4ee8 100644 --- a/shopfloor/tests/test_cluster_picking_scan.py +++ b/shopfloor/tests/test_cluster_picking_scan.py @@ -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 @@ -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 diff --git a/shopfloor/views/stock_picking_type.xml b/shopfloor/views/stock_picking_type.xml index 25313e1586..ad90a59d5b 100644 --- a/shopfloor/views/stock_picking_type.xml +++ b/shopfloor/views/stock_picking_type.xml @@ -5,9 +5,15 @@ stock.picking.type - - - + + + + + +