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
  • workcenter_id
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:
            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'

Back to entity