mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
Allow changing a putaway tray type after assigned
When the shuttle screen propose a tray based on a tray type and we are in the 'save' step, where we are supposed to physically putaway the good and save, we should still be able to change the tray type to fetch another tray.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user