diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 7aef5fcbd1f..987991bcad3 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -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?