From 931fa2f65fd635f6e5ba855c71f8ba251e299f68 Mon Sep 17 00:00:00 2001 From: Michael Tietz Date: Wed, 3 Apr 2024 21:56:14 +0200 Subject: [PATCH] [FIX] shopfloor_reception: Ensure state assign of remainig move --- shopfloor_reception/services/reception.py | 4 +- .../tests/test_set_destination.py | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/shopfloor_reception/services/reception.py b/shopfloor_reception/services/reception.py index b70f9b3b64f..7b13d315577 100644 --- a/shopfloor_reception/services/reception.py +++ b/shopfloor_reception/services/reception.py @@ -1305,7 +1305,6 @@ def _auto_post_line(self, selected_line): new_move = move.create(split_move_vals) new_move.move_line_ids = selected_line new_move._action_confirm(merge=False) - new_move._recompute_state() new_move._action_assign() # Set back the quantity to do on one of the lines line = fields.first( @@ -1318,7 +1317,8 @@ def _auto_post_line(self, selected_line): move.product_uom_qty, line[0].product_uom_id ) line.product_uom_qty = move_quantity - move._recompute_state() + else: + move._action_assign() new_move.extract_and_action_done() def set_destination( diff --git a/shopfloor_reception/tests/test_set_destination.py b/shopfloor_reception/tests/test_set_destination.py index 802f6d4b02e..e0917a16232 100644 --- a/shopfloor_reception/tests/test_set_destination.py +++ b/shopfloor_reception/tests/test_set_destination.py @@ -199,3 +199,42 @@ def test_auto_posting_concurent_work(self): self.assertEqual(picking.state, "assigned") # So the quantity left to do on the current move has decreased self.assertEqual(move.product_uom_qty, 9) + + def test_auto_posting_partial_new_pack(self): + self.menu.sudo().auto_post_line = True + picking = self._create_picking() + selected_move_line = picking.move_line_ids.filtered( + lambda l: l.product_id == self.product_a + ) + package_name = "FooBar" + self.service.dispatch( + "set_quantity", + params={ + "barcode": package_name, + "confirmation": "", + "picking_id": picking.id, + "quantity": 8, + "selected_line_id": selected_move_line.id, + }, + ) + self.service.dispatch( + "set_quantity", + params={ + "barcode": package_name, + "confirmation": package_name, + "picking_id": picking.id, + "quantity": 8, + "selected_line_id": selected_move_line.id, + }, + ) + self.service.dispatch( + "set_destination", + params={ + "confirmation": True, + "location_name": self.dispatch_location.name, + "picking_id": picking.id, + "selected_line_id": selected_move_line.id, + }, + ) + move = picking.move_lines.filtered(lambda m: m.product_id == self.product_a) + self.assertEqual(move.state, "assigned")