Merge PR #1987 into 16.0

Signed-off-by rousseldenis
This commit is contained in:
OCA-git-bot
2024-07-25 14:24:06 +00:00
2 changed files with 73 additions and 2 deletions

View File

@@ -151,6 +151,77 @@ class TestMoveLocation(TestsCommon):
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 123.0],
)
def test_planned_transfer_strict(self):
product = self.env["product.product"].create(
{"name": "Test", "type": "product", "tracking": "lot"}
)
lot = self.env["stock.lot"].create(
{
"name": "Test lot",
"product_id": product.id,
}
)
self.set_product_amount(
product,
self.internal_loc_1,
10.0,
)
self.set_product_amount(
product,
self.internal_loc_1,
10.0,
lot_id=lot,
)
wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2)
wizard.onchange_origin_location()
wizard = wizard.with_context(planned=True)
location_lines = wizard.stock_move_location_line_ids.filtered(
lambda r: r.product_id.id != product.id or r.lot_id.id != lot.id
)
location_lines.unlink()
wizard.action_move_location()
picking = wizard.picking_id
self.assertEqual(picking.state, "assigned")
self.assertEqual(
len(wizard.stock_move_location_line_ids), len(picking.move_line_ids)
)
location_line = wizard.stock_move_location_line_ids
wizard_lines = [
location_line.product_id.id,
location_line.lot_id.id,
location_line.move_quantity,
]
line = picking.move_line_ids
picking_lines = [line.product_id.id, line.lot_id.id, line.reserved_uom_qty]
self.assertEqual(
wizard_lines,
picking_lines,
"Mismatch between move location lines and move lines",
)
self.assertEqual(
picking.move_line_ids.reserved_uom_qty,
10.0,
)
# Create planned transfer for same quant
wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2)
wizard.onchange_origin_location()
wizard = wizard.with_context(planned=True)
location_lines = wizard.stock_move_location_line_ids.filtered(
lambda r: r.product_id.id != product.id or r.lot_id.id != lot.id
)
location_lines.unlink()
wizard.action_move_location()
picking = wizard.picking_id
self.assertEqual(picking.state, "assigned")
self.assertEqual(
len(wizard.stock_move_location_line_ids), len(picking.move_line_ids)
)
self.assertEqual(
picking.move_line_ids.mapped("reserved_uom_qty"),
[0.0],
)
def test_quant_transfer(self):
"""Test quants transfer."""
quants = self.product_lots.stock_quant_ids

View File

@@ -230,7 +230,7 @@ class StockMoveLocationWizard(models.TransientModel):
lot_id=line.lot_id,
package_id=line.package_id,
owner_id=line.owner_id,
strict=False,
strict=True,
)
move._update_reserved_quantity(
line.move_quantity,
@@ -239,7 +239,7 @@ class StockMoveLocationWizard(models.TransientModel):
lot_id=line.lot_id,
package_id=line.package_id,
owner_id=line.owner_id,
strict=False,
strict=True,
)
# Force the state to be assigned, instead of _action_assign,
# to avoid discarding the selected move_location_line.