mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[14.0][FIX] stock_move_location: Fix onchange and make editable
This commit is contained in:
@@ -258,3 +258,17 @@ class TestMoveLocation(TestsCommon):
|
|||||||
second_line = wizard.stock_move_location_line_ids[1]
|
second_line = wizard.stock_move_location_line_ids[1]
|
||||||
second_line.product_id = False
|
second_line.product_id = False
|
||||||
self.assertEqual(second_line._get_available_quantity(), (0, 0))
|
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)
|
||||||
|
|||||||
@@ -155,8 +155,11 @@ class StockMoveLocationWizard(models.TransientModel):
|
|||||||
|
|
||||||
@api.onchange("destination_location_id")
|
@api.onchange("destination_location_id")
|
||||||
def _onchange_destination_location_id(self):
|
def _onchange_destination_location_id(self):
|
||||||
|
if self.env.context.get("active_model", False) == "stock.quant":
|
||||||
for line in self.stock_move_location_line_ids:
|
for line in self.stock_move_location_line_ids:
|
||||||
line.destination_location_id = self.destination_location_id
|
line.destination_location_id = self.destination_location_id
|
||||||
|
else:
|
||||||
|
self.create_lines()
|
||||||
|
|
||||||
def _clear_lines(self):
|
def _clear_lines(self):
|
||||||
self.stock_move_location_line_ids = False
|
self.stock_move_location_line_ids = False
|
||||||
@@ -332,6 +335,10 @@ class StockMoveLocationWizard(models.TransientModel):
|
|||||||
not self.env.context.get("origin_location_disable")
|
not self.env.context.get("origin_location_disable")
|
||||||
and self.origin_location_id
|
and self.origin_location_id
|
||||||
):
|
):
|
||||||
|
self.create_lines()
|
||||||
|
|
||||||
|
def create_lines(self):
|
||||||
|
self._clear_lines()
|
||||||
lines = []
|
lines = []
|
||||||
line_model = self.env["wiz.stock.move.location.line"]
|
line_model = self.env["wiz.stock.move.location.line"]
|
||||||
for line_val in self._get_stock_move_location_lines_values():
|
for line_val in self._get_stock_move_location_lines_values():
|
||||||
|
|||||||
@@ -64,11 +64,7 @@
|
|||||||
readonly="1"
|
readonly="1"
|
||||||
force_save="1"
|
force_save="1"
|
||||||
/>
|
/>
|
||||||
<field
|
<field name="destination_location_id" />
|
||||||
name="destination_location_id"
|
|
||||||
readonly="1"
|
|
||||||
force_save="1"
|
|
||||||
/>
|
|
||||||
<field
|
<field
|
||||||
name="lot_id"
|
name="lot_id"
|
||||||
domain="[('product_id', '=', product_id)]"
|
domain="[('product_id', '=', product_id)]"
|
||||||
|
|||||||
Reference in New Issue
Block a user