diff --git a/shopfloor_reception/services/reception.py b/shopfloor_reception/services/reception.py index ffdaf6e424..6cb10e60ab 100644 --- a/shopfloor_reception/services/reception.py +++ b/shopfloor_reception/services/reception.py @@ -718,14 +718,11 @@ def _check_location_ok(self, location, selected_line, picking): if location.usage == "view": return (False, False) - move_dest_location = selected_line.location_dest_id - pick_type_dest_location = picking.picking_type_id.default_location_dest_id - - move_dest_location_ok = location.parent_path.startswith( - move_dest_location.parent_path + move_dest_location_ok = self.is_dest_location_valid( + selected_line.move_id, location ) - pick_type_dest_location_ok = location.parent_path.startswith( - pick_type_dest_location.parent_path + pick_type_dest_location_ok = self.is_dest_location_valid( + selected_line.move_id, location, pick_type=True ) if move_dest_location_ok or pick_type_dest_location_ok: return (move_dest_location_ok, pick_type_dest_location_ok) diff --git a/shopfloor_reception/tests/test_set_destination.py b/shopfloor_reception/tests/test_set_destination.py index 2c730360ce..5235933bac 100644 --- a/shopfloor_reception/tests/test_set_destination.py +++ b/shopfloor_reception/tests/test_set_destination.py @@ -17,6 +17,13 @@ def _change_line_dest(cls, line): # for move's dest_location and pick type's dest_location line.location_dest_id = cls.location_dest + @classmethod + def _change_dest(cls, move): + # Modify the location dest on the move, so we have different children + # for move's dest_location and pick type's dest_location + move.location_dest_id = cls.location_dest + move.picking_id.location_dest_id = cls.location_dest + def test_scan_location_child_of_dest_location(self): picking = self._create_picking() selected_move_line = picking.move_line_ids.filtered( @@ -31,9 +38,17 @@ def test_scan_location_child_of_dest_location(self): "location_name": self.shelf2.name, }, ) - self.assertEqual(selected_move_line.location_dest_id, self.shelf2) + # scanned location should be child of picking destination or picking type one + self.assertEqual(selected_move_line.location_dest_id, self.stock_location) + data = self.data.picking(picking) self.assert_response( - response, next_state="select_move", data=self._data_for_select_move(picking) + response, + next_state="set_destination", + data={ + "picking": data, + "selected_move_line": self.data.move_lines(selected_move_line), + }, + message={"message_type": "error", "body": "You cannot place it here"}, ) def test_scan_location_child_of_pick_type_dest_location(self): @@ -41,7 +56,7 @@ def test_scan_location_child_of_pick_type_dest_location(self): selected_move_line = picking.move_line_ids.filtered( lambda l: l.product_id == self.product_a ) - self._change_line_dest(selected_move_line) + self._change_dest(selected_move_line.move_id) response = self.service.dispatch( "set_destination", params={