From 67aadf5a107c3cb3c680e4ae1675609c07f8e2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Tue, 1 Dec 2020 14:07:32 +0100 Subject: [PATCH] [FIX] stock_vertical_lift: handles multiple move lines on pick If there is two move lines for the same product in the vertical lift (stored in2 differents trays for instance), the pick scenario was failing when the user was processing the first line. To circumvent this, instead of validating directly the move, we put the line in its own stock move, then we put the stock move in its own transfer and validate this one. Methods used to do that have been copied from the `shopfloor` module, they probably deserves their own module as they are quite generic. --- .../demo/stock_inventory_demo.xml | 22 +++++- .../models/vertical_lift_operation_base.py | 77 ++++++++++++++++++- stock_vertical_lift/tests/common.py | 9 ++- stock_vertical_lift/tests/test_pick.py | 6 +- 4 files changed, 105 insertions(+), 9 deletions(-) diff --git a/stock_vertical_lift/demo/stock_inventory_demo.xml b/stock_vertical_lift/demo/stock_inventory_demo.xml index 9c9e4a4cd..a523b3e80 100644 --- a/stock_vertical_lift/demo/stock_inventory_demo.xml +++ b/stock_vertical_lift/demo/stock_inventory_demo.xml @@ -7,7 +7,27 @@ - 30.0 + 10.0 + + + + + + + 10.0 + + + + + + + 10.0 %s." + ) + % (picking.id, picking.name) + ) + moves_todo.write({"picking_id": new_picking.id}) + moves_todo.package_level_id.write({"picking_id": new_picking.id}) + moves_todo.move_line_ids.write({"picking_id": new_picking.id}) + moves_todo.move_line_ids.package_level_id.write( + {"picking_id": new_picking.id} + ) + new_picking.action_assign() + assert new_picking.state == "assigned" + new_picking.action_done() + return True + + +# /methods + + class VerticalLiftOperationBase(models.AbstractModel): """Base model for shuttle operations (pick, put, inventory)""" @@ -412,7 +485,9 @@ class VerticalLiftOperationTransfer(models.AbstractModel): line = self.current_move_line_id if line.state in ("assigned", "partially_available"): line.qty_done = line.product_qty - line.move_id._action_done() + # if the move has other move lines, it is split to have only this move line + split_other_move_lines(line.move_id, line) + extract_and_action_done(line.move_id) return True def fetch_tray(self): diff --git a/stock_vertical_lift/tests/common.py b/stock_vertical_lift/tests/common.py index 541064c8d..e87853267 100644 --- a/stock_vertical_lift/tests/common.py +++ b/stock_vertical_lift/tests/common.py @@ -154,10 +154,11 @@ class VerticalLiftCase(common.LocationTrayTypeCase): inventory.action_start() return inventory - def _test_button_release(self, move_line, expected_state): - # for the test, we'll consider our last line has been delivered - move_line.qty_done = move_line.product_qty - move_line.move_id._action_done() + def _test_button_release(self, move_lines, expected_state): + # for the test, we'll consider all the lines has been delivered + for move_line in move_lines: + move_line.qty_done = move_line.product_qty + move_lines.picking_id.action_done() # release, no further operation in queue operation = self.shuttle._operation_for_mode() # the release button can be used only in the state... release diff --git a/stock_vertical_lift/tests/test_pick.py b/stock_vertical_lift/tests/test_pick.py index 28f5618d6..1d4d3b4f2 100644 --- a/stock_vertical_lift/tests/test_pick.py +++ b/stock_vertical_lift/tests/test_pick.py @@ -13,7 +13,7 @@ class TestPick(VerticalLiftCase): ) # we have a move line to pick created by demo picking # stock_picking_out_demo_vertical_lift_1 - cls.out_move_line = cls.picking_out.move_line_ids + cls.out_move_line = cls.picking_out.move_line_ids[0] def test_switch_pick(self): self.shuttle.switch_pick() @@ -159,7 +159,7 @@ class TestPick(VerticalLiftCase): def test_button_release(self): self._open_screen("pick") - self._test_button_release(self.out_move_line, "noop") + self._test_button_release(self.picking_out.move_line_ids, "noop") def test_process_current_pick(self): operation = self._open_screen("pick") @@ -183,7 +183,7 @@ class TestPick(VerticalLiftCase): # fmt: off 'cells': [ [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 1, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0], ] # fmt: on },