[FIX] mrp: state on workorder with 0 batch size

Usecase:
- Go on a BoM with a routing. Go on the first operation and set
the next operation(batch field) as 'Once a minimum number of products is
processed'.
- Set the batch size (minimum operation) to 0.
- Create a MO and plan it.
- The second work order has state 'pending' instead of 'ready'

It happens because the system automatically set the first wo as
'ready' and the following as 'pending' and don't check the batch
and batch_size.

closes odoo/odoo#32628

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
Arnold Moyaux
2019-04-11 13:21:54 +00:00
parent 2a88e0197a
commit c9d3653f48
2 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -583,7 +583,7 @@ class MrpProduction(models.Model):
})
if workorders:
workorders[-1].next_work_order_id = workorder.id
workorders[-1]._init_nextworkorder_states()
workorders[-1]._start_nextworkorder()
workorders += workorder
# assign moves; last operation receive all unassigned moves (which case ?)
+10 -9
View File
@@ -337,9 +337,6 @@ class MrpWorkorder(models.Model):
move_line.lot_produced_id = self.final_lot_id.id
move_line.done_wo = True
# One a piece is produced, you can launch the next work order
self._start_nextworkorder()
self.move_line_ids.filtered(
lambda move_line: not move_line.done_move and not move_line.lot_produced_id and move_line.qty_done > 0
).write({
@@ -390,6 +387,9 @@ class MrpWorkorder(models.Model):
self.final_lot_id.use_next_on_work_order_id = self.next_work_order_id
self.final_lot_id = False
# One a piece is produced, you can launch the next work order
self._start_nextworkorder()
# Set a qty producing
rounding = self.production_id.product_uom_id.rounding
if float_compare(self.qty_produced, self.production_id.product_qty, precision_rounding=rounding) >= 0:
@@ -411,12 +411,13 @@ class MrpWorkorder(models.Model):
@api.multi
def _start_nextworkorder(self):
for record in self:
if record.next_work_order_id.state == 'pending':
record.next_work_order_id.state = 'ready'
def _init_nextworkorder_states(self):
return 'pending'
rounding = self.product_id.uom_id.rounding
if self.next_work_order_id.state == 'pending' and (
(self.operation_id.batch == 'no' and
float_compare(self.qty_production, self.qty_produced, precision_rounding=rounding) <= 0) or
(self.operation_id.batch == 'yes' and
float_compare(self.operation_id.batch_size, self.qty_produced, precision_rounding=rounding) <= 0)):
self.next_work_order_id.state = 'ready'
@api.multi
def button_start(self):