diff --git a/shopfloor_reception/services/reception.py b/shopfloor_reception/services/reception.py index 4f48dec001..5e322b5037 100644 --- a/shopfloor_reception/services/reception.py +++ b/shopfloor_reception/services/reception.py @@ -789,7 +789,7 @@ def _before_state__set_quantity(self, picking, line, message=None): return self._response_for_set_quantity(picking, line, message=message) 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( @@ -1068,7 +1068,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") @@ -1078,12 +1078,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 @@ -1108,7 +1108,7 @@ def set_quantity( selected_line_id, quantity=None, barcode=None, - confirmation=False, + confirmation=None, ): """Set the quantity done @@ -1414,7 +1414,7 @@ def set_quantity(self): }, "quantity": {"type": "float"}, "barcode": {"type": "string"}, - "confirmation": {"type": "boolean"}, + "confirmation": {"type": "string", "nullable": True}, } def process_with_existing_pack(self): @@ -1622,7 +1622,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 cb5a218048..9f94e79dc8 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 de4fed4db3..b78b283a9f 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 ea50f0f365..db35bc9fcd 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 7878eef0fe..21fe675814 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 a3b08ad5b3..23614c1ab8 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, ) diff --git a/shopfloor_reception_mobile/static/src/scenario/reception_states.js b/shopfloor_reception_mobile/static/src/scenario/reception_states.js index fca90f6e80..67e1c269fd 100644 --- a/shopfloor_reception_mobile/static/src/scenario/reception_states.js +++ b/shopfloor_reception_mobile/static/src/scenario/reception_states.js @@ -183,7 +183,7 @@ export const reception_states = function () { selected_line_id: this.line_being_handled.id, quantity: this.scan_destination_qty, barcode: barcode.text, - confirmation: this.state.data.confirmation_required, + confirmation: this.state.data.confirmation_required || "", }) ); }, @@ -240,6 +240,7 @@ export const reception_states = function () { picking_id: this.state.data.picking.id, selected_line_id: this.line_being_handled.id, location_name: location.text, + // FIXME if it is always set to true, it is not really used ? confirmation: true, }) ); diff --git a/shopfloor_reception_packaging_dimension/tests/test_set_package_dimension.py b/shopfloor_reception_packaging_dimension/tests/test_set_package_dimension.py index 64c6fae553..468e1bbc93 100644 --- a/shopfloor_reception_packaging_dimension/tests/test_set_package_dimension.py +++ b/shopfloor_reception_packaging_dimension/tests/test_set_package_dimension.py @@ -153,7 +153,7 @@ def test_set_multiple_packaging_dimension(self): data={ "picking": self.data.picking(self.picking), "selected_move_line": self.data.move_lines(line), - "confirmation_required": False, + "confirmation_required": None, }, message=self.msg_store.packaging_dimension_updated( self.product_c_packaging_2