[FIX] mrp: correctly update lot_product_id to final lot for stock.move.lots

When there are 3 different lots reserved for 3 different serial
numbers for the final product, if you do the first finished product, the
finished lot is put on all stock.move.lots even if nothing has been
consumed for it.

This results in traceability report for the first finished lot being linked
to all of lots instead of just the one that was consumed.

Now we update lot_produced_id only on stock.move.lots where quantity_done > 0.
That way it will only links with the correct one.
This commit is contained in:
Josse Colpaert
2016-11-10 17:32:15 +01:00
committed by Thibault Delavallée
parent ff56304f58
commit 7e15fa59e4
+6 -3
View File
@@ -300,9 +300,12 @@ class MrpWorkorder(models.Model):
if self.next_work_order_id and self.final_lot_id and not self.next_work_order_id.final_lot_id:
self.next_work_order_id.final_lot_id = self.final_lot_id.id
# TODO: add filter for those that have not been done yet --> need to check as it can have different filters
self.move_lot_ids.filtered(lambda x: not x.done_move and not x.lot_produced_id).write({'lot_produced_id': self.final_lot_id.id,
'lot_produced_qty': self.qty_producing,})
self.move_lot_ids.filtered(
lambda move_lot: not move_lot.done_move and not move_lot.lot_produced_id and move_lot.quantity_done > 0
).write({
'lot_produced_id': self.final_lot_id.id,
'lot_produced_qty': self.qty_producing
})
# If last work order, then post lots used
# TODO: should be same as checking if for every workorder something has been done?