Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] mrp: start the next workorder in a function to allow for overrides #31774

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+11 −2
Diff settings

Always

Just for now

@@ -583,6 +583,7 @@ def _workorders_create(self, bom, bom_data):
})
if workorders:
workorders[-1].next_work_order_id = workorder.id
workorders[-1]._init_nextworkorder_states()

This comment has been minimized.

Copy link
@Whenrow

Whenrow Apr 1, 2019

Contributor

it's already done line 580

This comment has been minimized.

Copy link
@len-odoo

len-odoo Apr 1, 2019

Author Contributor

No, l580 we give it an initial value (for all but the first, pending) but if there is a batch_size of 0, then we want to allow workorders to start in parallel.
That's why we go over the state once again, but using the info from workorders[-1] to decide what its state should really be (although it's only really used in mrp_workorder...).

This comment has been minimized.

Copy link
@Whenrow

Whenrow Apr 2, 2019

Contributor

ok you are right

workorders += workorder

# assign moves; last operation receive all unassigned moves (which case ?)
@@ -338,8 +338,7 @@ def record_production(self):
move_line.done_wo = True

# One a piece is produced, you can launch the next work order
if self.next_work_order_id.state == 'pending':
self.next_work_order_id.state = 'ready'
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
@@ -409,6 +408,15 @@ def record_production(self):
self.button_finish()
return True

@api.multi
def _start_nextworkorder(self):
for record in self:

This comment has been minimized.

Copy link
@fmdl

fmdl Mar 13, 2019

Contributor

one write for better performance : self.mapped('next_work_order_id').filtered(lambda x: x.state == 'pending').write({'state':'ready'})

if record.next_work_order_id.state == 'pending':
record.next_work_order_id.state = 'ready'

def _init_nextworkorder_states(self):
return 'pending'

@api.multi
def button_start(self):
self.ensure_one()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.