diff --git a/stock_move_location/tests/test_move_location.py b/stock_move_location/tests/test_move_location.py
index 376c21ef1..b8eeced3f 100644
--- a/stock_move_location/tests/test_move_location.py
+++ b/stock_move_location/tests/test_move_location.py
@@ -258,3 +258,17 @@ class TestMoveLocation(TestsCommon):
second_line = wizard.stock_move_location_line_ids[1]
second_line.product_id = False
self.assertEqual(second_line._get_available_quantity(), (0, 0))
+
+ def test_wizard_different_destinations(self):
+ """
+ Create a picking whose line destinations are differents. The first line is sent
+ to the origin location.
+ """
+ wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2)
+ wizard.onchange_origin_location()
+ wizard.stock_move_location_line_ids[0].write(
+ {"destination_location_id": self.internal_loc_1.id}
+ )
+ wizard.action_move_location()
+ locations = self.internal_loc_1 + self.internal_loc_2
+ self.assertEqual(wizard.picking_id.move_line_ids.location_dest_id, locations)
diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py
index 9ee15a760..19a4b282a 100644
--- a/stock_move_location/wizard/stock_move_location.py
+++ b/stock_move_location/wizard/stock_move_location.py
@@ -155,8 +155,11 @@ class StockMoveLocationWizard(models.TransientModel):
@api.onchange("destination_location_id")
def _onchange_destination_location_id(self):
- for line in self.stock_move_location_line_ids:
- line.destination_location_id = self.destination_location_id
+ if self.env.context.get("active_model", False) == "stock.quant":
+ for line in self.stock_move_location_line_ids:
+ line.destination_location_id = self.destination_location_id
+ else:
+ self.create_lines()
def _clear_lines(self):
self.stock_move_location_line_ids = False
@@ -332,18 +335,22 @@ class StockMoveLocationWizard(models.TransientModel):
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:
- continue
- line = line_model.create(line_val)
- line.max_quantity = line.get_max_quantity()
- line.reserved_quantity = line.reserved_quantity
- lines.append(line)
- self.update(
- {"stock_move_location_line_ids": [(6, 0, [line.id for line in lines])]}
- )
+ self.create_lines()
+
+ def create_lines(self):
+ self._clear_lines()
+ 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:
+ continue
+ line = line_model.create(line_val)
+ line.max_quantity = line.get_max_quantity()
+ line.reserved_quantity = line.reserved_quantity
+ lines.append(line)
+ self.update(
+ {"stock_move_location_line_ids": [(6, 0, [line.id for line in lines])]}
+ )
def clear_lines(self):
self._clear_lines()
diff --git a/stock_move_location/wizard/stock_move_location.xml b/stock_move_location/wizard/stock_move_location.xml
index a42da5cca..59838ab65 100644
--- a/stock_move_location/wizard/stock_move_location.xml
+++ b/stock_move_location/wizard/stock_move_location.xml
@@ -64,11 +64,7 @@
readonly="1"
force_save="1"
/>
-
+