[REF]hr_holidays_timeoff_analysis: code refactoring
Some checks failed
pre-commit / pre-commit (pull_request) Has been cancelled

This commit is contained in:
2026-07-21 11:48:43 +02:00
parent d5fb46f3cf
commit e5d56d9d1a
2 changed files with 16 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
{
"name": "hr_holidays_timeoff_analysis",
"version": "18.0.1.0.0",
"version": "18.0.1.1.0",
"author": "Elabore",
"website": "https://git.elabore.coop/elabore/elabore-addons",
"maintainer": "Elabore",

View File

@@ -18,12 +18,12 @@ class TimeOffDay(models.Model):
hr_leave_type = fields.Many2one(related="hr_leave_id.holiday_status_id")
leave_duration_by_day = fields.Float()
def employee_is_scheduled_to_work_this_day(self, date, employee, leave):
def employee_is_scheduled_to_work_this_day(self, date, employee, leave=None):
"""
Check if the employee is scheduled to work on this day according to his
calendar.
"""
calendar = self.get_calendar(employee, date)
calendar = self._get_calendar_for_leave(employee, date, leave)
if not calendar or not calendar.attendance_ids:
return False
day_of_week = str(date.weekday())
@@ -41,7 +41,19 @@ class TimeOffDay(models.Model):
)
return bool(attendances)
def get_calendar(self, employee, date, leave=None):
def _get_calendar_for_leave(self, employee, date, leave=None):
"""
Return the calendar to use to know whether ``employee`` works on
``date`` for a given ``leave``.
The base implementation ignores ``leave`` and returns the employee's
regular working calendar. It is an extension point: the module
``hr_holidays_timeoff_analysis_l10n_fr_hr_holidays`` overrides it to
force the company calendar for French reference leaves.
"""
return self.get_calendar(employee, date)
def get_calendar(self, employee, date):
"""
Get the working time calendar of the employee.
"""