[FIX]hr_employee_stats_sheet:fix bug in _get_total_recovery_hours and _get_total_leave_hours for half-days request unit leaves

This commit is contained in:
2026-06-15 16:54:38 +02:00
parent b65b6431b6
commit 2f73c1b3a7
3 changed files with 196 additions and 19 deletions

View File

@@ -121,15 +121,15 @@ class HrEmployeeStats(models.Model):
("request_date_to", ">=", self.date),
],
)
if recovery_ids:
for recovery_id in recovery_ids:
if recovery_id.request_unit_hours:
recovery_hours = recovery_id.number_of_hours_display
total_recovery_hours += min(recovery_hours,self._get_total_planned_hours())
elif recovery_id.request_unit_half:
total_recovery_hours += self._get_total_planned_hours() / 2
else :
total_recovery_hours += self._get_total_planned_hours()
for recovery_id in recovery_ids:
if recovery_id.request_date_from == recovery_id.request_date_to:
# single-day request (hours or half-day):
# Odoo already computed the hours from the calendar
total_recovery_hours += recovery_id.number_of_hours_display
else:
# multi-day request: we take the planned hours
# of THAT specific day
total_recovery_hours += self._get_total_planned_hours()
return total_recovery_hours
def _get_total_leave_hours(self):
@@ -147,15 +147,15 @@ class HrEmployeeStats(models.Model):
("active", '=', True),
],
)
if leave_ids:
for leave_id in leave_ids:
if leave_id.request_unit_hours:
leave_hours = leave_id.number_of_hours_display
total_leave_hours += min(leave_hours,self._get_total_planned_hours())
elif leave_id.request_unit_half:
total_leave_hours += self._get_total_planned_hours() / 2
else :
total_leave_hours += self._get_total_planned_hours()
for leave_id in leave_ids:
if leave_id.request_date_from == leave_id.request_date_to:
# single-day request (hours or half-day):
# Odoo already computed the hours from the calendar
total_leave_hours += leave_id.number_of_hours_display
else:
# multi-day request: we take the planned hours
# of THAT specific day
total_leave_hours += self._get_total_planned_hours()
return total_leave_hours
@api.depends("employee_id", "date")