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

Module: HR Gamification

Entity: gamification.badge

Compute Method: _compute_granted_employees_count

View 18.0 View 20.0
Inputs Method Outputs
  • id
+ user_count = dict(
+             self.env['gamification.badge.user']._read_group(
+                 [('badge_id', 'in', self.ids), ('employee_id', '!=', False)],
+                 ['badge_id'], ['__count'],
+             ),
+         )
for badge in self:
-             badge.granted_employees_count = self.env['gamification.badge.user'].search_count([
-                 ('badge_id', '=', badge.id),
-                 ('employee_id', '!=', False)
-             ])
+             badge.granted_employees_count = user_count.get(badge._origin, 0)
  • granted_employees_count

Back to entity