-
- Downloads
[FIX] hr_holidays: speedup Time Off dashboard
When opening the Time Off App, the JS performs an rpc to call hr_leave_type.get_days_all_request. Inside this method there are some __get__ on non-stored computed fields. This triggers a recomputation of said fields in _compute_leaves. _compute_leaves uses _get_employees_days_per_allocation. When there is an hr.leave.type with request_unit = 'hour', you may get lots of validated allocations by employee. When this is the case, _get_employees_days_per_allocation gets quite slow, especially the last part about 'Future available leaves'. This commit optimizes this part of _get_employees_days_per_allocation. In this part the allocations are grouped by employees and Intervals instances are of the form (start, stop, records). This means that for a given employee_id, all the records of one Intervals will have the same start and stop values. This allows us to move the call to _get_work_days_data_batch outside of the for future_allocation_interval in future_allocation_intervals._items loop. Because _get_work_days_data_batch is quite expansive, moving it out grealty speeds up the _get_employees_days_per_allocation method. Example speedup: in a database with 50 validated allocations for the same hr.leave.type and employee_id, the timing of _get_employees_days_per_allocation 7.39s -> 158ms opw-3123457 closes odoo/odoo#117754 X-original-commit: 5a2efd2e Signed-off-by:Kevin Baptiste <kba@odoo.com>
Loading
Please register or sign in to comment