diff --git a/stock_vertical_lift/models/vertical_lift_operation_put.py b/stock_vertical_lift/models/vertical_lift_operation_put.py index 886575b86..0b9b6e573 100644 --- a/stock_vertical_lift/models/vertical_lift_operation_put.py +++ b/stock_vertical_lift/models/vertical_lift_operation_put.py @@ -65,15 +65,22 @@ class VerticalLiftOperationPut(models.Model): _("No move line found for barcode {}").format(barcode) ) - elif self.step() == "scan_tray_type": + elif self.step() in ("scan_tray_type", "save"): + # note: we must be able to scan a different tray type when we are + # in the save step too, in case we couldn't put it in the first one + # for some reason. tray_type = self._find_tray_type(barcode) if tray_type: if self._assign_available_cell(tray_type): self.fetch_tray() - self.next_step() + if self.step() == "scan_tray_type": + # when we are in "save" step, stay here + self.next_step() else: self.env.user.notify_warning( - _("No free space for this tray type in this shuttle.") + _('No free space for tray type "{}" in this shuttle.').format( + tray_type.display_name + ) ) else: self.env.user.notify_warning( @@ -152,6 +159,7 @@ class VerticalLiftOperationPut(models.Model): ) if location: self.current_move_line_id.location_dest_id = location + self.current_move_line_id.package_level_id.location_dest_id = location return True return False diff --git a/stock_vertical_lift/tests/common.py b/stock_vertical_lift/tests/common.py index 717134df7..541064c8d 100644 --- a/stock_vertical_lift/tests/common.py +++ b/stock_vertical_lift/tests/common.py @@ -35,6 +35,9 @@ class VerticalLiftCase(common.LocationTrayTypeCase): cls.location_1a_x1y2 = cls.env.ref( "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a_x1y2" ) + cls.location_1b = cls.env.ref( + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1b" + ) cls.location_1b_x1y1 = cls.env.ref( "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1b_x1y1" ) diff --git a/stock_vertical_lift/tests/test_put.py b/stock_vertical_lift/tests/test_put.py index 814c6d112..75f16e03b 100644 --- a/stock_vertical_lift/tests/test_put.py +++ b/stock_vertical_lift/tests/test_put.py @@ -87,10 +87,29 @@ class TestPut(VerticalLiftCase): operation.on_barcode_scanned(self.location_1a.tray_type_id.code) self.assertEqual(operation.state, "save") # a cell has been set + self.assertTrue( + self.in_move_line.location_dest_id in self.location_1a.child_ids + ) + + def test_change_tray_type_on_save(self): + operation = self._open_screen("put") + move_line = self.in_move_line + # assume we already scanned the product and the tray type + # and the assigned location was location_1a_x1y1 + operation.current_move_line_id = move_line + move_line.location_dest_id = self.location_1a_x1y1 + operation.state = "save" + # we want to use another tray with a different type though, + # so we scan again + operation.on_barcode_scanned(self.location_1b.tray_type_id.code) self.assertTrue( self.in_move_line.location_dest_id in self.shuttle.location_id.child_ids.child_ids ) + # we are still in save + self.assertEqual(operation.state, "save") + # a cell has been set in the other tray + self.assertTrue(move_line.location_dest_id in self.location_1b.child_ids) def test_transition_scan_tray_type_no_empty_cell(self): operation = self._open_screen("put")