Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Manufacturing
Entity: mrp.workorder
Compute Method: _compute_state
| Inputs | Method | Outputs |
|---|---|---|
|
for workorder in self: - if workorder.state not in ('pending', 'waiting', 'ready'): - continue - no_recursion_blocked_by_workorder_ids = workorder.blocked_by_workorder_ids.with_context(no_recursion=True) - if workorder.production_availability == 'assigned': - if all(wo.state in ('done', 'cancel') for wo in no_recursion_blocked_by_workorder_ids): - workorder.state = 'ready' - else: - workorder.state = 'pending' - continue - if self._context.get('no_recursion'): + if not workorder.product_uom_id or workorder.state not in ('blocked', 'ready'): continue - if no_recursion_blocked_by_workorder_ids and not all(wo.state in ('done', 'cancel') for wo in no_recursion_blocked_by_workorder_ids): - workorder.state = 'pending' + has_qty_ready = workorder.product_uom_id.compare(workorder.qty_ready, 0) > 0 + if has_qty_ready: + workorder.write({'state': 'ready'}) else: - workorder.state = 'waiting' + workorder.write({'state': 'blocked'}) |
|
