[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:
Goffin Simon
2017-06-28 14:51:27 +02:00
parent a93195ee4e
commit ecdf96e8a7
2 changed files with 12 additions and 3 deletions
+6
View File
@@ -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
+6 -3
View File
@@ -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