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

Module: Time Off

Entity: hr.leave.accrual.plan

Compute Method: _compute_employee_count

Inputs Method Outputs
  • id
allocations_read_group = self.env['hr.leave.allocation']._read_group(
            [('accrual_plan_id', 'in', self.ids)],
            ['accrual_plan_id'],
            ['employee_id:count_distinct'],
        )
allocations_dict = {accrual_plan.id: count for accrual_plan, count in allocations_read_group}
for plan in self:
            plan.employees_count = allocations_dict.get(plan.id, 0)

Back to entity