From 0a84e5bed3e5e84e3b621cbf34182c73b70e109d Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Sat, 1 Feb 2020 00:14:12 +0100 Subject: [PATCH] [FIX] stock_move_location: Keep product lines when user launch wizard from stock quant view --- stock_move_location/tests/test_move_location.py | 2 ++ stock_move_location/wizard/stock_move_location.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/stock_move_location/tests/test_move_location.py b/stock_move_location/tests/test_move_location.py index 2b6250848..8e1a9d93e 100644 --- a/stock_move_location/tests/test_move_location.py +++ b/stock_move_location/tests/test_move_location.py @@ -92,6 +92,8 @@ class TestMoveLocation(TestsCommon): ) lines = wizard.stock_move_location_line_ids self.assertEqual(len(lines), 3) + wizard.onchange_origin_location() + self.assertEqual(len(lines), 3) wizard.destination_location_id = self.internal_loc_1 wizard._onchange_destination_location_id() self.assertEqual(lines.mapped("destination_location_id"), self.internal_loc_1) diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index a8f691cd8..b300af09c 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -226,8 +226,14 @@ class StockMoveLocationWizard(models.TransientModel): @api.onchange("origin_location_id") def onchange_origin_location(self): - lines = [] - if self.origin_location_id: + # Get origin_location_disable context key to prevent load all origin + # location products when user opens the wizard from stock quants to + # move it to other location. + if ( + not self.env.context.get("origin_location_disable") + and self.origin_location_id + ): + lines = [] line_model = self.env["wiz.stock.move.location.line"] for line_val in self._get_stock_move_location_lines_values(): if line_val.get("max_quantity") <= 0: @@ -235,7 +241,6 @@ class StockMoveLocationWizard(models.TransientModel): line = line_model.create(line_val) line.max_quantity = line.get_max_quantity() lines.append(line) - # self.stock_move_location_line_ids = [(4, line.id)] self.update( {"stock_move_location_line_ids": [(6, 0, [line.id for line in lines])]} )