Skip to content

Commit

Permalink
[FIX] mrp: extract move assignation to a function
Browse files Browse the repository at this point in the history
We extract move assignation to a function so that this behaviour can be
overriden.

opw 1909833
  • Loading branch information
len-odoo committed Dec 12, 2018
1 parent bc38850 commit 6cd7a4d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions addons/mrp/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,16 +571,20 @@ def _workorders_create(self, bom, bom_data):
workorders += workorder

# assign moves; last operation receive all unassigned moves (which case ?)
moves_raw = self.move_raw_ids.filtered(lambda move: move.operation_id == operation)
if len(workorders) == len(bom.routing_id.operation_ids):
moves_raw |= self.move_raw_ids.filtered(lambda move: not move.operation_id)
moves_finished = self.move_finished_ids.filtered(lambda move: move.operation_id == operation) #TODO: code does nothing, unless maybe by_products?
moves_raw.mapped('move_line_ids').write({'workorder_id': workorder.id})
(moves_finished + moves_raw).write({'workorder_id': workorder.id})
self._move_assign_workorder(bom, operation, workorder, workorders)

workorder._generate_lot_ids()
return workorders

def _move_assign_workorder(self, bom, operation, workorder, workorders):
moves_raw = self.move_raw_ids.filtered(lambda move: move.operation_id == operation)
if len(workorders) == len(bom.routing_id.operation_ids):
moves_raw |= self.move_raw_ids.filtered(lambda move: not move.operation_id)
moves_finished = self.move_finished_ids.filtered(
lambda move: move.operation_id == operation) # TODO: code does nothing, unless maybe by_products?
moves_raw.mapped('move_line_ids').write({'workorder_id': workorder.id})
(moves_finished + moves_raw).write({'workorder_id': workorder.id})

def _check_lots(self):
# Check that the raw materials were consumed for lots that we have produced.
if self.product_id.tracking != 'none':
Expand Down

0 comments on commit 6cd7a4d

Please sign in to comment.