[REF]hr_holidays_timeoff_analysis: code refactoring
Some checks failed
pre-commit / pre-commit (pull_request) Has been cancelled
Some checks failed
pre-commit / pre-commit (pull_request) Has been cancelled
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "hr_holidays_timeoff_analysis",
|
"name": "hr_holidays_timeoff_analysis",
|
||||||
"version": "18.0.1.0.0",
|
"version": "18.0.1.1.0",
|
||||||
"author": "Elabore",
|
"author": "Elabore",
|
||||||
"website": "https://git.elabore.coop/elabore/elabore-addons",
|
"website": "https://git.elabore.coop/elabore/elabore-addons",
|
||||||
"maintainer": "Elabore",
|
"maintainer": "Elabore",
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ class TimeOffDay(models.Model):
|
|||||||
hr_leave_type = fields.Many2one(related="hr_leave_id.holiday_status_id")
|
hr_leave_type = fields.Many2one(related="hr_leave_id.holiday_status_id")
|
||||||
leave_duration_by_day = fields.Float()
|
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
|
Check if the employee is scheduled to work on this day according to his
|
||||||
calendar.
|
calendar.
|
||||||
"""
|
"""
|
||||||
calendar = self.get_calendar(employee, date)
|
calendar = self._get_calendar_for_leave(employee, date, leave)
|
||||||
if not calendar or not calendar.attendance_ids:
|
if not calendar or not calendar.attendance_ids:
|
||||||
return False
|
return False
|
||||||
day_of_week = str(date.weekday())
|
day_of_week = str(date.weekday())
|
||||||
@@ -41,7 +41,19 @@ class TimeOffDay(models.Model):
|
|||||||
)
|
)
|
||||||
return bool(attendances)
|
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.
|
Get the working time calendar of the employee.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user