From c9ef529398f70a656cbc4a0a7865c33d766bd79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Tue, 21 Feb 2023 15:01:02 +0100 Subject: [PATCH] shopfloor, checkout: check lot on change confirmation --- shopfloor/actions/message.py | 9 +++++++++ shopfloor/services/checkout.py | 10 +++++----- shopfloor/tests/test_checkout_base.py | 2 +- shopfloor/tests/test_checkout_scan_line.py | 6 +++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/shopfloor/actions/message.py b/shopfloor/actions/message.py index 22c71d7232..2e08b9f22e 100644 --- a/shopfloor/actions/message.py +++ b/shopfloor/actions/message.py @@ -920,6 +920,15 @@ def lot_changed(self): "body": _("Lot changed"), } + def lot_change_wrong_lot(self, lot_name): + return { + "message_type": "error", + "body": _("Scanned lot differs from the previous scan: %(lot)s.") + % { + "lot": lot_name, + }, + } + def lot_change_no_line_found(self): return { "message_type": "error", diff --git a/shopfloor/services/checkout.py b/shopfloor/services/checkout.py index b099a072d1..5e9fa96600 100644 --- a/shopfloor/services/checkout.py +++ b/shopfloor/services/checkout.py @@ -41,7 +41,7 @@ class Checkout(Component): _description = __doc__ def _response_for_select_line( - self, picking, message=None, need_confirm_pack_all=False, need_confirm_lot=False + self, picking, message=None, need_confirm_pack_all=False, need_confirm_lot=None ): if all(line.shopfloor_checkout_done for line in picking.move_line_ids): return self._response_for_summary(picking, message=message) @@ -56,7 +56,7 @@ def _response_for_select_line( ) def _data_for_select_line( - self, picking, need_confirm_pack_all=False, need_confirm_lot=False + self, picking, need_confirm_pack_all=False, need_confirm_lot=None ): return { "picking": self._data_for_stock_picking(picking), @@ -425,7 +425,7 @@ def _deselect_lines(self, lines): {"qty_done": 0, "shopfloor_user_id": False} ) - def scan_line(self, picking_id, barcode, confirm_pack_all=False, confirm_lot=False): + def scan_line(self, picking_id, barcode, confirm_pack_all=False, confirm_lot=None): """Scan move lines of the stock picking It allows to select move lines of the stock picking for the next @@ -1559,7 +1559,7 @@ def scan_line(self): "required": False, }, "confirm_lot": { - "type": "boolean", + "type": "integer", "nullable": True, "required": False, }, @@ -1785,7 +1785,7 @@ def _schema_stock_picking_details(self): group_lines_by_location={"type": "boolean"}, show_oneline_package_content={"type": "boolean"}, need_confirm_pack_all={"type": "boolean"}, - need_confirm_lot={"type": "boolean"}, + need_confirm_lot={"type": "integer", "nullable": True}, ) @property diff --git a/shopfloor/tests/test_checkout_base.py b/shopfloor/tests/test_checkout_base.py index 0d8b120282..c5134ed85b 100644 --- a/shopfloor/tests/test_checkout_base.py +++ b/shopfloor/tests/test_checkout_base.py @@ -54,7 +54,7 @@ def _data_for_select_line(self, picking, **kw): "group_lines_by_location": True, "show_oneline_package_content": False, "need_confirm_pack_all": False, - "need_confirm_lot": False, + "need_confirm_lot": None, } data.update(kw) return data diff --git a/shopfloor/tests/test_checkout_scan_line.py b/shopfloor/tests/test_checkout_scan_line.py index 8cb39fdeed..c1bf4b8085 100644 --- a/shopfloor/tests/test_checkout_scan_line.py +++ b/shopfloor/tests/test_checkout_scan_line.py @@ -218,7 +218,7 @@ def test_scan_line_product_in_one_package_all_package_lines_ok(self): # more than one package, it would be an error. self._test_scan_line_ok(self.product_a.barcode, picking.move_line_ids) - def _test_scan_line_error(self, picking, barcode, message, need_confirm_lot=False): + def _test_scan_line_error(self, picking, barcode, message, need_confirm_lot=None): """Test errors for /scan_line :param picking: the picking we are currently working with (selected) @@ -351,7 +351,7 @@ def test_scan_line_error_lot_different_change_success(self): picking, lot.name, self.msg_store.lot_different_change(), - need_confirm_lot=True, + need_confirm_lot=lot.id, ) # Second scan to confirm the change of lot response = self.service.dispatch( @@ -359,7 +359,7 @@ def test_scan_line_error_lot_different_change_success(self): params={ "picking_id": picking.id, "barcode": lot.name, - "confirm_lot": True, + "confirm_lot": lot.id, }, ) message = self.msg_store.lot_replaced_by_lot(previous_lot, lot)