[WIP]hr_employee_stats_sheet:add domaine on recovery type

This commit is contained in:
2025-09-16 16:19:22 +02:00
parent 29976fb9a4
commit 80d27f4bbd
4 changed files with 16 additions and 3 deletions

View File

@@ -190,7 +190,10 @@ class HrTimesheetSheet(models.Model):
raise UserError(
_("Employe not defined for the timesheet sheet or recovery type not defined in settings")
)
if recovery_type_id.request_unit != 'hour' or not recovery_type_id.allows_negative:
raise UserError(
_("The recovery type must be set to 'Hours' and allow negative leaves in the settings")
)
# check if allocation already exists for this timesheet sheet, if yes, refuse it
allocations = (
self.env["hr.leave.allocation"]
@@ -217,7 +220,6 @@ class HrTimesheetSheet(models.Model):
data_days = recovery_type_id.get_employees_days([employee_id.id])[employee_id.id]
total_recovery_type_leaves = data_days.get(recovery_type_id.id,{})
total_virtual_remaining_recovery_type_leaves = total_recovery_type_leaves.get('virtual_remaining_leaves', 0)
# TODO vérifier si ça marche avec un recovery type dont l'unité de mesure est le jour
# add the recovery hours to the total remaining leaves recovery type, and check if the limit of recovery hours is exceeded
exceeded_hours = total_virtual_remaining_recovery_type_leaves + recovery_hours - max_allowed_recovery_hours
# if limit recovery hours is exceeded, don't create a new allocation