Skip to content

Commit 4e3f8e9

Browse files
committed
[IMP] shopfloor_reception: Use is_dest_location_valid
In order to uniformize the function calls, use `is_dest_location_valid` in `_check_location_ok` to validate the destination location.
1 parent 6c1c1d1 commit 4e3f8e9

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

shopfloor_reception/services/reception.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,11 @@ def _check_location_ok(self, location, selected_line, picking):
718718
if location.usage == "view":
719719
return (False, False)
720720

721-
move_dest_location = selected_line.location_dest_id
722-
pick_type_dest_location = picking.picking_type_id.default_location_dest_id
723-
724-
move_dest_location_ok = location.parent_path.startswith(
725-
move_dest_location.parent_path
721+
move_dest_location_ok = self.is_dest_location_valid(
722+
selected_line.move_id, location
726723
)
727-
pick_type_dest_location_ok = location.parent_path.startswith(
728-
pick_type_dest_location.parent_path
724+
pick_type_dest_location_ok = self.is_dest_location_valid(
725+
selected_line.move_id, location, pick_type=True
729726
)
730727
if move_dest_location_ok or pick_type_dest_location_ok:
731728
return (move_dest_location_ok, pick_type_dest_location_ok)

shopfloor_reception/tests/test_set_destination.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def _change_line_dest(cls, line):
1717
# for move's dest_location and pick type's dest_location
1818
line.location_dest_id = cls.location_dest
1919

20+
@classmethod
21+
def _change_dest(cls, move):
22+
# Modify the location dest on the move, so we have different children
23+
# for move's dest_location and pick type's dest_location
24+
move.location_dest_id = cls.location_dest
25+
move.picking_id.location_dest_id = cls.location_dest
26+
2027
def test_scan_location_child_of_dest_location(self):
2128
picking = self._create_picking()
2229
selected_move_line = picking.move_line_ids.filtered(
@@ -31,17 +38,25 @@ def test_scan_location_child_of_dest_location(self):
3138
"location_name": self.shelf2.name,
3239
},
3340
)
34-
self.assertEqual(selected_move_line.location_dest_id, self.shelf2)
41+
# scanned location should be child of picking destination or picking type one
42+
self.assertEqual(selected_move_line.location_dest_id, self.stock_location)
43+
data = self.data.picking(picking)
3544
self.assert_response(
36-
response, next_state="select_move", data=self._data_for_select_move(picking)
45+
response,
46+
next_state="set_destination",
47+
data={
48+
"picking": data,
49+
"selected_move_line": self.data.move_lines(selected_move_line),
50+
},
51+
message={"message_type": "error", "body": "You cannot place it here"},
3752
)
3853

3954
def test_scan_location_child_of_pick_type_dest_location(self):
4055
picking = self._create_picking()
4156
selected_move_line = picking.move_line_ids.filtered(
4257
lambda l: l.product_id == self.product_a
4358
)
44-
self._change_line_dest(selected_move_line)
59+
self._change_dest(selected_move_line.move_id)
4560
response = self.service.dispatch(
4661
"set_destination",
4762
params={

0 commit comments

Comments
 (0)