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_level_count

Inputs Method Outputs
  • id
level_read_group = self.env['hr.leave.accrual.level']._read_group(
            [('accrual_plan_id', 'in', self.ids)],
            groupby=['accrual_plan_id'],
            aggregates=['__count'],
        )
mapped_count = {accrual_plan.id: count for accrual_plan, count in level_read_group}
for plan in self:
            plan.level_count = mapped_count.get(plan.id, 0)

Back to entity