Skip to content
Snippets Groups Projects
Commit 99b9874a authored by Simon Lejeune's avatar Simon Lejeune
Browse files

[FIX] mrp, purchase_mrp: purchase_line_id also with kits

When confirming a move for a kit, it is basically unlinked and replaced
by moves for its component. The link to the purchase line was kept in
v10, but since rev[1] it is not anymore. Make an helper to get the
values and override it in purchase_mrp to add the purchase line link.

[1] https://github.com/odoo/odoo/commit/8248f0e153ae5fcc1449d0d05149b61df615ad4f

opw 779497
parent a4740861
No related branches found
No related tags found
No related merge requests found
......@@ -173,16 +173,19 @@ class StockMove(models.Model):
self.sudo().unlink()
return processed_moves
def _prepare_phantom_move_values(self, bom_line, quantity):
return {
'picking_id': self.picking_id.id if self.picking_id else False,
'product_id': bom_line.product_id.id,
'product_uom': bom_line.product_uom_id.id,
'product_uom_qty': quantity,
'state': 'draft', # will be confirmed below
'name': self.name,
}
def _generate_move_phantom(self, bom_line, quantity):
if bom_line.product_id.type in ['product', 'consu']:
return self.copy(default={
'picking_id': self.picking_id.id if self.picking_id else False,
'product_id': bom_line.product_id.id,
'product_uom': bom_line.product_uom_id.id,
'product_uom_qty': quantity,
'state': 'draft', # will be confirmed below
'name': self.name,
})
return self.copy(default=self._prepare_phantom_move_values(bom_line, quantity))
return self.env['stock.move']
def _generate_consumed_move_line(self, qty_to_add, final_lot, lot=False):
......
......@@ -28,3 +28,14 @@ class PurchaseOrderLine(models.Model):
return self.product_qty
else:
return 0.0
class StockMove(models.Model):
_inherit = 'stock.move'
def _prepare_phantom_move_values(self, bom_line, quantity):
vals = super(StockMove, self)._prepare_phantom_move_values(bom_line, quantity)
if self.purchase_line_id:
vals['purchase_line_id'] = self.purchase_line_id.id
return vals
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