|
|
"""The value of full_time_required_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:
hours = item.stored_full_time_required_hours
if item.auto_generate and item.flexible_hours:
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)
hours = (
(
sum(
c.stored_full_time_required_hours
for c in calendars.calendar_id
)
)
if calendars
else False
)
item.full_time_required_hours = hours
|
|