Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Employees

Entity: hr.department

Compute Method: _compute_plan_count

Inputs Method Outputs
  • id
plans_data = self.env['mail.activity.plan']._read_group(
            domain=[
                '|',
                ('department_id', '=', False),
                ('department_id', 'in', self.ids),
                ('company_id', 'in', self.env.companies.ids + [False])
            ],
            groupby=['department_id'],
            aggregates=['__count'],
        )
plans_count = {department.id: count for department, count in plans_data}
for department in self:
            department.plans_count = plans_count.get(department.id, 0) + plans_count.get(False, 0)

Back to entity