[FIX] mrp, stock: Traceability of MO disappears when product returned after delivery
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
This commit is contained in:
@@ -11,3 +11,9 @@ class StockQuant(models.Model):
|
||||
'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
|
||||
|
||||
@@ -334,12 +334,15 @@ class Quant(models.Model):
|
||||
# price update + accounting entries adjustments
|
||||
solved_quants._price_update(solving_quant.cost)
|
||||
# merge history (and cost?)
|
||||
solved_quants.write({
|
||||
'history_ids': [(4, history_move.id) for history_move in solving_quant.history_ids]
|
||||
})
|
||||
solved_quants.write(solving_quant._prepare_history())
|
||||
solving_quant.with_context(force_unlink=True).unlink()
|
||||
solving_quant = remaining_solving_quant
|
||||
|
||||
def _prepare_history(self):
|
||||
return {
|
||||
'history_ids': [(4, history_move.id) for history_move in self.history_ids],
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def _price_update(self, newprice):
|
||||
# TDE note: use ACLs instead of sudoing everything
|
||||
|
||||
Reference in New Issue
Block a user