|
|
"""The value of stored_flexible_hours is defined unless the calendar is
auto_generate; in that case, the hours for the applicable calendars will
be defined based on the dates specified by context.
"""
for item in self:
flexible_hours = item.stored_flexible_hours
if item.auto_generate:
from_date = self.env.context.get("flexible_hours_from_date")
to_date = self.env.context.get("flexible_hours_to_date")
employee = fields.first(item.employee_ids)
if (from_date or to_date) and employee:
calendars = employee._get_planning_calendars(from_date, to_date)
flexible_hours = (
any(c.stored_flexible_hours for c in calendars.calendar_id)
if calendars
else False
)
item.flexible_hours = flexible_hours
|
|