From a2ebda5898504a41d1f68db9f4aa3f07a86b4202 Mon Sep 17 00:00:00 2001 From: Laetitia Da Costa Date: Tue, 16 Dec 2025 14:55:43 +0100 Subject: [PATCH] [REF]hr_employee_stats_sheet:delete max allowed recovery hours limitation --- .../models/hr_timesheet_sheet.py | 47 ------------------- 1 file changed, 47 deletions(-) diff --git a/hr_employee_stats_sheet/models/hr_timesheet_sheet.py b/hr_employee_stats_sheet/models/hr_timesheet_sheet.py index fc4df64..fa43e6f 100644 --- a/hr_employee_stats_sheet/models/hr_timesheet_sheet.py +++ b/hr_employee_stats_sheet/models/hr_timesheet_sheet.py @@ -100,28 +100,6 @@ class HrTimesheetSheet(models.Model): sheet.recovery_allocation_ids.write({"state": "refuse"}) return res - def _get_working_hours_per_week(self): - """ - Get the weekly working hours for the employee, which is defined by: - - the employee's work contract, - - or their resource calendar, - - or the company's resource calendar, - - or the default value of 40 hours per week. - :return: limit recovery hours - """ - # get ressource calendar id used during the timesheet sheet time period - ressource_calendar_id = self.employee_id._get_calendar_in_progress_during_a_time_period(self.date_start,self.date_end) - if ressource_calendar_id: - resource_calendar_attendance_ids = self.env[ - "resource.calendar.attendance" - ].search([("calendar_id", "=", ressource_calendar_id.id)]) - # calculate working hours per week according to the employee's resource calendar - weekly_working_hours = 0 - for day in resource_calendar_attendance_ids: - weekly_working_hours += day.hour_to - day.hour_from - return weekly_working_hours - return HOURS_PER_DAY * 5 - def _get_working_hours_per_day(self): """ Get the hours per day for the employee according to: @@ -137,12 +115,6 @@ class HrTimesheetSheet(models.Model): return ressource_calendar_id.hours_per_day return HOURS_PER_DAY - def _get_max_allowed_recovery_hours(self): - """ - Get the maximum number of hours beyond which new recovery allowances cannot be created - """ - return self._get_working_hours_per_week() - def action_generate_recovery_allocation(self): # check if the user has the right to review the timesheet sheet self.ensure_one() @@ -175,25 +147,6 @@ class HrTimesheetSheet(models.Model): # get recovery hours from total gap hours of the timesheet sheet recovery_hours = self._get_timesheet_sheet_recovery_hours() - # get recovery hours cap - max_allowed_recovery_hours = self._get_max_allowed_recovery_hours() - if max_allowed_recovery_hours: - # find recovery remaining leaves for the employee - recovery_type_id = self.env.company.recovery_type_id - # get virtual remaining leaves for the employee and the recovery leaves type - 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) - # 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 - if exceeded_hours > 0: - raise UserError( - _( - "The number of recovery hours exceeds the authorized limit (%s h) by %s hours" - ) - % (max_allowed_recovery_hours, exceeded_hours) - ) # convert recovery hours into days recovery_days = recovery_hours / self._get_working_hours_per_day()