mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] stock_move_location: Keep product lines when user launch wizard from stock quant view
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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])]}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user