From cced243bb273b1c98be1faebba67b926f6f1cd71 Mon Sep 17 00:00:00 2001 From: Thierry Ducrest Date: Tue, 14 Nov 2023 15:55:00 +0100 Subject: [PATCH] shopfloor: checkout fix asking destination location There could be multiple moves with different destination The destination location could be of type `view` For both cases, require the user to scan a new location. --- shopfloor/services/checkout.py | 12 ++++-------- shopfloor/tests/test_checkout_done.py | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/shopfloor/services/checkout.py b/shopfloor/services/checkout.py index 9494bb1c767..1aae3754b19 100644 --- a/shopfloor/services/checkout.py +++ b/shopfloor/services/checkout.py @@ -1404,15 +1404,11 @@ def done(self, picking_id, confirmation=False): }, ) lines_done = self._lines_checkout_done(picking) - dest_location = picking.location_dest_id - if self.work.menu.ask_for_leaf_destination_location: - child_locations = self.env["stock.location"].search( - [("id", "child_of", dest_location.id), ("usage", "!=", "view")] + dest_location = lines_done.move_id.location_dest_id + if len(dest_location) != 1 or dest_location.usage == "view": + return self._response_for_select_child_location( + picking, ) - if len(child_locations) > 0 and child_locations != dest_location: - return self._response_for_select_child_location( - picking, - ) stock = self._actions_for("stock") stock.validate_moves(lines_done.move_id) return self._response_for_select_document( diff --git a/shopfloor/tests/test_checkout_done.py b/shopfloor/tests/test_checkout_done.py index ccd2b173c25..c7e912f99ad 100644 --- a/shopfloor/tests/test_checkout_done.py +++ b/shopfloor/tests/test_checkout_done.py @@ -75,9 +75,20 @@ def test_done_partial_confirm(self): data={"restrict_scan_first": False}, ) - def test_done_partial_confirm_ask_leaf_location(self): - """Check confirm partially done with force leaf location option on.""" - self.menu.sudo().ask_for_leaf_destination_location = True + def test_done_ask_destination_location(self): + """Check asking for destination location for view type location.""" + view_location = ( + self.env["stock.location"] + .sudo() + .create( + { + "name": "Test Location Usage View", + "location_id": self.picking.move_lines.location_dest_id.id, + "usage": "view", + } + ) + ) + self.picking.move_lines.location_dest_id = view_location response = self.service.dispatch( "done", params={"picking_id": self.picking.id, "confirmation": True} )