Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions shopfloor_reception/services/reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 18 additions & 3 deletions shopfloor_reception/tests/test_set_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -31,17 +38,25 @@ 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):
picking = self._create_picking()
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={
Expand Down
Loading