Steps to reproduce: Let's consider product P tracked by serial number P has a manufacture BOM B with Q as componenent - Produce P with serial number SN(with MO) - Send P with SN to a customer A(with SO and DO) - Force availability on P to a customer B(with SO and DO) - Return P to stock for customer A. Bug: The tracability for P removed the component Q(consumed_quant_ids) when reconciling the negative quant(generated for B) with the returned quant from A. opw:744424
20 lines
753 B
Python
20 lines
753 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class StockQuant(models.Model):
|
|
_inherit = 'stock.quant'
|
|
|
|
consumed_quant_ids = fields.Many2many(
|
|
'stock.quant', 'stock_quant_consume_rel', 'produce_quant_id', 'consume_quant_id')
|
|
produced_quant_ids = fields.Many2many(
|
|
'stock.quant', 'stock_quant_consume_rel', 'consume_quant_id', 'produce_quant_id')
|
|
|
|
def _prepare_history(self):
|
|
vals = super(StockQuant, self)._prepare_history()
|
|
vals['consumed_quant_ids'] = [(4, quant.id) for quant in self.consumed_quant_ids]
|
|
vals['produced_quant_ids'] = [(4, quant.id) for quant in self.produced_quant_ids]
|
|
return vals
|