[FIX] hr_holidays: show sum of closest allocations
In the time off dashboard, only the number of available days of the first closest allocation to expire was shown, which is not correct. If you have many allocations expiring on the same day, their sum should be shown. task-3203519 closes odoo/odoo#114010 X-original-commit: ff35654ae8c44014aab99ec07493f035e9a2d80d Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -432,7 +432,15 @@ class HolidaysType(models.Model):
|
||||
def _get_days_request(self):
|
||||
self.ensure_one()
|
||||
result = self._get_employees_days_per_allocation(self.closest_allocation_to_expire.employee_id.ids)
|
||||
closest_allocation_remaining = result[self.closest_allocation_to_expire.employee_id.id][self][self.closest_allocation_to_expire]['virtual_remaining_leaves']
|
||||
closest_allocation_remaining = 0
|
||||
if self.closest_allocation_to_expire:
|
||||
# Shows the sum of allocation expiring on the same day as the closest to expire
|
||||
employee_allocations = result[self.closest_allocation_to_expire.employee_id.id][self].items()
|
||||
closest_allocation_remaining = sum(
|
||||
res['virtual_remaining_leaves']
|
||||
for alloc, res in employee_allocations
|
||||
if alloc and alloc.date_to == self.closest_allocation_to_expire.date_to
|
||||
)
|
||||
return (self.name, {
|
||||
'remaining_leaves': ('%.2f' % self.remaining_leaves).rstrip('0').rstrip('.'),
|
||||
'virtual_remaining_leaves': ('%.2f' % self.virtual_remaining_leaves).rstrip('0').rstrip('.'),
|
||||
|
||||
Reference in New Issue
Block a user