Skip to content
Snippets Groups Projects
Commit 5f7648bb authored by Arnold Moyaux's avatar Arnold Moyaux
Browse files

[FIX] mrp: failing test multi mrp step


It's due to MRP refactoring that confirm raw moves before finished
moves. It implies that in _assign picking, SFP with final product
will search a picking but the stock.move do not have a created_production_id
and it will be merged inside the intermediate SFP (it works before
because it was the intermediate SFP that was merged in the finished SFP).

_key_assign_picking is also added if multiple moves are confirmed w/
and w/h created_production_id, we won't merge them in the same picking.

closes odoo/odoo#36335

Signed-off-by: default avatarChristophe Simonis <chs@odoo.com>
parent 64135889
No related branches found
No related tags found
No related merge requests found
......@@ -233,10 +233,13 @@ class StockMove(models.Model):
res = super(StockMove, self)._should_be_assigned()
return bool(res and not (self.production_id or self.raw_material_production_id))
def _key_assign_picking(self):
keys = super(StockMove, self)._key_assign_picking()
return keys + (self.created_production_id,)
def _search_picking_for_assignation_domain(self):
res = super(StockMove, self)._search_picking_for_assignation_domain()
if self.created_production_id:
res.append(('move_lines.created_production_id', '=', self.created_production_id.id))
res.append(('move_lines.created_production_id', '=', self.created_production_id.id))
return res
def _compute_kit_quantities(self, product_id, kit_qty, kit_bom, filters):
......
......@@ -165,6 +165,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
production_form.product_id = self.complex_product
production_form.picking_type_id = self.warehouse.manu_type_id
production = production_form.save()
production.action_confirm()
move_raw_ids = production.move_raw_ids
self.assertEqual(len(move_raw_ids), 2)
......@@ -197,23 +198,31 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
# Picking: SFP PostProcessing -> Stock
## Stick from Subprocess
picking = pickings[1]
picking = self.env['stock.picking'].search([
('move_lines.product_id', '=', self.finished_product.id),
('location_dest_id', '=', self.warehouse.lot_stock_id.id),
('group_id', '=', production.procurement_group_id.id)
])
self.assertEqual(len(picking.move_lines), 1)
picking.product_id = self.finished_product
# Picking: PC Stock -> Preprocessing
## Stick
## Raw Iron
picking = pickings[0]
picking = self.env['stock.picking'].search([
('move_lines.product_id', 'in', [self.finished_product.id, self.raw_product_2.id]),
('location_id', '=', self.warehouse.lot_stock_id.id),
('group_id', '=', production.procurement_group_id.id)
])
self.assertEqual(len(picking.move_lines), 2)
picking.move_lines[0].product_id = self.finished_product
picking.move_lines[1].product_id = self.raw_product_2
# Picking: SFP PostProcessing -> Stock
## Arrow from this process
picking = pickings[2]
picking = picking = self.env['stock.picking'].search([
('move_lines.product_id', '=', self.complex_product.id),
('location_dest_id', '=', self.warehouse.lot_stock_id.id),
('group_id', '=', production.procurement_group_id.id)
])
self.assertEqual(len(picking.move_lines), 1)
picking.product_id = self.complex_product
def test_manufacturing_flow(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment