Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Employee Calendar Planning

Entity: resource.calendar

Compute Method: _compute_flexible_hours

Inputs Method Outputs
"""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

Back to entity