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_total_employee

Inputs Method Outputs
  • id
emp_data = self.env['hr.employee'].sudo()._read_group([('department_id', 'in', self.ids), ('company_id', 'in', self.env.companies.ids)], ['department_id'], ['__count'])
result = {department.id: count for department, count in emp_data}
for department in self:
            department.total_employee = result.get(department.id, 0)

Back to entity