[FIX] hr_employee: remove duplicates from working_hours computation

Since the computation of employees work intervals is done in batch,
i.e. 1 call to _work_intervals for each (tz, resource_calendar_id) pairs,
removing tz duplicates from mapped results improves
the perf of hr_presence_state/hr_icon_display computations.

This is especially true for grouped hr.employee kanban view as each column
search_read triggers a recompute for these fields.

closes odoo/odoo#71772

X-original-commit: be6d4a2523bb1a292908d09dfc5393bc0aa88a2d
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Aurélien (avd)
2021-06-04 16:03:22 +00:00
parent 5b5cfd0beb
commit 8c7e6d5dec
+1 -1
View File
@@ -172,7 +172,7 @@ class HrEmployeeBase(models.AbstractModel):
def _get_employee_working_now(self):
working_now = []
# We loop over all the employee tz and the resource calendar_id to detect working hours in batch.
all_employee_tz = self.mapped('tz')
all_employee_tz = set(self.mapped('tz'))
for tz in all_employee_tz:
employee_ids = self.filtered(lambda e: e.tz == tz)
resource_calendar_ids = employee_ids.mapped('resource_calendar_id')