diff --git a/shopfloor_reception/services/reception.py b/shopfloor_reception/services/reception.py index 107ae5e6973..b3266397718 100644 --- a/shopfloor_reception/services/reception.py +++ b/shopfloor_reception/services/reception.py @@ -781,7 +781,7 @@ def _align_product_uom_qties(self, move): line.product_uom_qty = line.qty_done + remaining_todo def _response_for_set_quantity( - self, picking, line, message=None, asking_confirmation=False + self, picking, line, message=None, asking_confirmation=None ): self._align_product_uom_qties(line.move_id) return self._response( @@ -1060,7 +1060,7 @@ def _set_quantity__get_handlers_by_type(self): } def _set_quantity__by_barcode( - self, picking, selected_line, barcode, confirmation=False + self, picking, selected_line, barcode, confirmation=None ): handlers_by_type = self._set_quantity__get_handlers_by_type() search = self._actions_for("search") @@ -1070,12 +1070,12 @@ def _set_quantity__by_barcode( return handler(picking, selected_line, search_result.record) # Nothing found, ask user if we should create a new pack for the scanned # barcode - if not confirmation: + if confirmation != barcode: return self._response_for_set_quantity( picking, selected_line, message=self.msg_store.create_new_pack_ask_confirmation(barcode), - asking_confirmation=True, + asking_confirmation=barcode, ) package = self.env["stock.quant.package"].create({"name": barcode}) selected_line.result_package_id = package @@ -1100,7 +1100,7 @@ def set_quantity( selected_line_id, quantity=None, barcode=None, - confirmation=False, + confirmation=None, ): """Set the quantity done @@ -1406,7 +1406,7 @@ def set_quantity(self): }, "quantity": {"type": "float"}, "barcode": {"type": "string"}, - "confirmation": {"type": "boolean"}, + "confirmation": {"type": "string"}, } def process_with_existing_pack(self): @@ -1614,7 +1614,7 @@ def _schema_set_quantity(self): }, "picking": {"type": "dict", "schema": self.schemas.picking()}, "confirmation_required": { - "type": "boolean", + "type": "string", "nullable": True, "required": False, }, diff --git a/shopfloor_reception/tests/test_return_scan_line.py b/shopfloor_reception/tests/test_return_scan_line.py index cb5a2180487..9f94e79dc82 100644 --- a/shopfloor_reception/tests/test_return_scan_line.py +++ b/shopfloor_reception/tests/test_return_scan_line.py @@ -43,7 +43,7 @@ def test_scan_product_in_delivery(self): response, next_state="set_quantity", data={ - "confirmation_required": False, + "confirmation_required": None, "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), }, @@ -94,7 +94,7 @@ def test_scan_packaging_in_delivery(self): response, next_state="set_quantity", data={ - "confirmation_required": False, + "confirmation_required": None, "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), }, diff --git a/shopfloor_reception/tests/test_return_set_quantity.py b/shopfloor_reception/tests/test_return_set_quantity.py index de4fed4db3c..b78b283a9f0 100644 --- a/shopfloor_reception/tests/test_return_set_quantity.py +++ b/shopfloor_reception/tests/test_return_set_quantity.py @@ -39,7 +39,7 @@ def _dispatch(self, quantity=None, barcode=None): def _get_data(self): return { - "confirmation_required": False, + "confirmation_required": None, "picking": self.data.picking(self.return_picking), "selected_move_line": self.data.move_lines(self.selected_move_line), } diff --git a/shopfloor_reception/tests/test_select_move.py b/shopfloor_reception/tests/test_select_move.py index ea50f0f365a..db35bc9fcd8 100644 --- a/shopfloor_reception/tests/test_select_move.py +++ b/shopfloor_reception/tests/test_select_move.py @@ -87,7 +87,7 @@ def test_scan_lot(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) @@ -112,7 +112,7 @@ def test_scan_not_tracked_product(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) @@ -137,7 +137,7 @@ def test_scan_not_tracked_packaging(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) diff --git a/shopfloor_reception/tests/test_set_lot_confirm.py b/shopfloor_reception/tests/test_set_lot_confirm.py index 7878eef0fe6..21fe675814e 100644 --- a/shopfloor_reception/tests/test_set_lot_confirm.py +++ b/shopfloor_reception/tests/test_set_lot_confirm.py @@ -61,6 +61,6 @@ def test_ensure_expiry_date(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) diff --git a/shopfloor_reception/tests/test_set_quantity.py b/shopfloor_reception/tests/test_set_quantity.py index a3b08ad5b33..23614c1ab80 100644 --- a/shopfloor_reception/tests/test_set_quantity.py +++ b/shopfloor_reception/tests/test_set_quantity.py @@ -62,7 +62,7 @@ def test_set_quantity_scan_product(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) @@ -89,7 +89,7 @@ def test_set_quantity_scan_packaging(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) @@ -115,7 +115,7 @@ def test_scan_product(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) # Scan again, and ensure qty increments @@ -167,7 +167,7 @@ def test_scan_packaging(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, ) # Scan again, and ensure qty increments @@ -227,7 +227,7 @@ def test_scan_package_with_destination_not_child_of_dest_location(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, message={"message_type": "error", "body": "You cannot place it here"}, ) @@ -300,7 +300,7 @@ def test_scan_location_not_child_of_dest_location(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, message={"message_type": "error", "body": "You cannot place it here"}, ) @@ -328,7 +328,7 @@ def test_scan_location_view_usage(self): data={ "picking": data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": False, + "confirmation_required": None, }, message={"message_type": "error", "body": "You cannot place it here"}, ) @@ -355,7 +355,7 @@ def test_scan_new_package(self): data={ "picking": picking_data, "selected_move_line": self.data.move_lines(selected_move_line), - "confirmation_required": True, + "confirmation_required": "FooBar", }, message={ "message_type": "warning", @@ -368,7 +368,7 @@ def test_scan_new_package(self): "picking_id": picking.id, "selected_line_id": selected_move_line.id, "barcode": "FooBar", - "confirmation": True, + "confirmation": "FooBar", }, ) self.assertEqual(selected_move_line.result_package_id.name, "FooBar") @@ -382,6 +382,52 @@ def test_scan_new_package(self): }, ) + def test_reception_set_quantity_confirm_new_package_with_other_new_pack(self): + picking = self._create_picking() + selected_move_line = picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_a + ) + selected_move_line.shopfloor_user_id = self.env.uid + # Scan new pack 1 + response = self.service.dispatch( + "set_quantity", + params={ + "picking_id": picking.id, + "selected_line_id": selected_move_line.id, + "barcode": "Pack1", + }, + ) + data = { + "picking": self.data.picking(picking), + "selected_move_line": self.data.move_lines(selected_move_line), + "confirmation_required": "Pack1", + } + # System ask for confimation for Pack 1 + self.assert_response( + response, + next_state="set_quantity", + data=data, + message=self.msg_store.create_new_pack_ask_confirmation("Pack1"), + ) + # Scan new pack 2 + response = self.service.dispatch( + "set_quantity", + params={ + "picking_id": picking.id, + "selected_line_id": selected_move_line.id, + "barcode": "Pack2", + "confirmation": "Pack1", + }, + ) + # System ask for confimation for Pack 2 + data["confirmation_required"] = "Pack2" + self.assert_response( + response, + next_state="set_quantity", + data=data, + message=self.msg_store.create_new_pack_ask_confirmation("Pack2"), + ) + @classmethod def _shopfloor_manager_values(cls): vals = super()._shopfloor_manager_values() @@ -516,7 +562,7 @@ def test_concurrent_update(self): data={ "picking": picking_data, "selected_move_line": self.data.move_lines(line), - "confirmation_required": False, + "confirmation_required": None, }, message=error_msg, )