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.workcenter
Compute Method: _compute_working_state
| Inputs | Method | Outputs |
|---|---|---|
|
+ time_log_by_workcenter = {} + for time_log in self.env['mrp.workcenter.productivity'].search([ + ('workcenter_id', 'in', self.ids), + ('date_end', '=', False), + ]): + wc = time_log.workcenter_id + if wc not in time_log_by_workcenter: + time_log_by_workcenter[wc] = time_log for workcenter in self: - # We search for a productivity line associated to this workcenter having no `date_end`. - # If we do not find one, the workcenter is not currently being used. If we find one, according - # to its `type_loss`, the workcenter is either being used or blocked. - time_log = self.env['mrp.workcenter.productivity'].search([ - ('workcenter_id', '=', workcenter.id), - ('date_end', '=', False) - ], limit=1) + time_log = time_log_by_workcenter.get(workcenter._origin) if not time_log: # the workcenter is not being used workcenter.working_state = 'normal' elif time_log.loss_type in ('productive', 'performance'): # the productivity line has a `loss_type` that means the workcenter is being used workcenter.working_state = 'done' else: # the workcenter is blocked workcenter.working_state = 'blocked' |
|
