Working schedules

A working schedule (resource.calendar) describes when work is expected. It is made of attendances (resource.calendar.attendance), the expected work slots, and leaves (resource.calendar.leaves), the periods interrupting them. Every resource, hence every employee, has a calendar; each company has a default one (res.company.resource_calendar_id).

This page explains these three models, then the methods used to compute work intervals, durations and dates from them.

其他资料

Intervals and Conventions, which apply to every method described below.

Calendar types

The calendar_type field determines how attendances are defined:

fixed (default)

Undated attendances repeated every week on their dayofweek ('0' is Monday). This is the regular “Monday to Friday, 8:00-12:00 and 13:00-17:00” schedule. hours_per_week, days_per_week and hours_per_day are computed from the attendances.

variable

Dated attendances (date), optionally recurring: recurrency_type (days or weeks), recurrency_interval, recurrency_end_type (forever, times or date) and the list of excluded occurrences. Multi-week rotations (e.g. one week out of two) are variable calendars with recurring attendances. hours_per_week and hours_per_day are set manually.

undefined (flexible)

No attendance at all: the resource works whenever it wants, optionally within an hours_per_week and an hours_per_day target. When both targets are zero, the calendar is fully flexible and the resource is considered as working the whole time. See Flexible calendars.

Switching the type of a calendar deletes the attendances that do not fit the new type.

Attendances

An attendance is either:

  • timed: hour_from and hour_to are set, as float hours in the local time of the resource (16.5 is 16:30, 24 is the end of the day);

  • duration-based: only duration_hours is set (e.g. 8 hours on Monday). When intervals are generated, the duration-based attendances of a day are placed one after the other, centered on 12:00. The default calendar of a company is built this way, so its intervals are 8:00-16:00.

A day cannot mix both kinds. day_period (morning, afternoon or full_day) is computed from the hours; it is used to request half days of time off.

Leaves

A resource.calendar.leaves record is a period during which the calendar’s attendances do not apply:

  • without resource_id, it is a global leave (typically a public holiday): it applies to every resource of its company using the calendar;

  • with a resource_id, it only applies to that resource. Validated time off requests create such leaves.

count_as tells whether the leave is an absence (default) or counts as working_time (e.g. a training). Leave methods only deduct absences by default.

date_from and date_to are datetime fields, hence naive UTC datetimes in the database.

Computing work intervals

Four methods generate the intervals of a calendar for a period, in batch for several resources. They all follow the conventions of the module.

_attendance_intervals_batch()

The theoretical work intervals generated by the attendances, leaves not deducted. Each interval carries its attendance as payload.

_leave_intervals_batch()

The leave intervals: global leaves, plus the leaves of each resource. Each interval carries its leaves as payload.

_work_intervals_batch()

The effective work intervals: attendance intervals minus leave intervals. This is the method to use to know when resources actually work, and the one other modules override to alter the result (e.g. hr_work_entry).

_unavailable_intervals_batch()

The complement of the work intervals within the period, in UTC. Used by Gantt views to grey out unavailable time.

_leave_intervals and _unavailable_intervals are single-resource shortcuts.

Example

A 38-hour calendar (8:00-12:00 and 13:00-16:36, Monday to Friday) with a public holiday on Tuesday, and two resources in different timezones, r2 being sick on Wednesday morning.

from datetime import datetime
from zoneinfo import ZoneInfo

from odoo.fields import Command

calendar = env['resource.calendar'].create({
    'name': 'Standard 38 hours/week',
    'attendance_ids': [Command.clear()] + [
        Command.create({'dayofweek': str(day), 'hour_from': hour_from, 'hour_to': hour_to})
        for day in range(5)
        for hour_from, hour_to in ((8, 12), (13, 16.6))
    ],
})
r1 = env['resource.resource'].create({
    'name': 'R1', 'calendar_id': calendar.id, 'tz': 'Asia/Kolkata',
})
r2 = env['resource.resource'].create({
    'name': 'R2', 'calendar_id': calendar.id, 'tz': 'Europe/Brussels',
})
env['resource.calendar.leaves'].create([{
    'name': 'Public holiday',  # global leave: no resource
    'calendar_id': calendar.id,
    'date_from': datetime(2026, 10, 20, 0, 0),  # naive UTC
    'date_to': datetime(2026, 10, 20, 22, 0),
}, {
    'name': 'Sick',
    'resource_id': r2.id,
    'date_from': datetime(2026, 10, 21, 6, 0),
    'date_to': datetime(2026, 10, 21, 10, 0),
}])

brussels = ZoneInfo('Europe/Brussels')
start = datetime(2026, 10, 19, tzinfo=brussels)
end = datetime(2026, 10, 24, tzinfo=brussels)
resources_per_tz = (r1 | r2)._get_resources_per_tz()

attendances = calendar._attendance_intervals_batch(start, end, resources_per_tz)
list(attendances)  # [r1.id, False, r2.id]
next(iter(attendances[r2.id]))
# (datetime(2026, 10, 19, 8, 0, tzinfo=ZoneInfo('Europe/Brussels')),
#  datetime(2026, 10, 19, 12, 0, tzinfo=ZoneInfo('Europe/Brussels')),
#  resource.calendar.attendance(...))
next(iter(attendances[r1.id]))[0]
# datetime(2026, 10, 19, 8, 0, tzinfo=ZoneInfo('Asia/Kolkata')): 8:00 local time

work = calendar._work_intervals_batch(start, end, resources_per_tz)
{
    key: sum((stop - start).total_seconds() / 3600 for start, stop, _ in intervals)
    for key, intervals in work.items()
}
# {r1.id: 30.4, False: 30.4, r2.id: 26.4}

Computing durations

When only a quantity of work is needed, use:

get_work_hours_count()

The number of calendar-level work hours between two dates or datetimes. Only global leaves are deducted (no resource).

get_work_duration_data()

The calendar-level work duration as {'days': float, 'hours': float}.

_get_attendance_intervals_days_data()

Converts any work intervals into {'days': float, 'hours': float}. A day counts for half a day if its hours are at most 3/4 of the reference hours of that day, otherwise for a full day.

For a specific resource or employee, use the methods of resource.mixin instead, which also deduct the leaves of the resource.

Example

With the calendar of the previous example:

calendar.get_work_hours_count(start, end)                        # 30.4
calendar.get_work_hours_count(start, end, compute_leaves=False)  # 38.0
calendar.get_work_duration_data(start, end)  # {'days': 4.0, 'hours': 30.4}

重要

With timezone-aware datetimes, get_work_hours_count reads the attendance hours in the timezone of the given datetimes. Passing UTC datetimes to compute the hours of a Brussels calendar reads 8:00-12:00 as 8:00-12:00 UTC. Pass datetimes in the right timezone, or dates (interpreted in the company’s timezone).

Planning and dates

plan_hours()

Returns the datetime at which a given number of work hours, starting from a datetime, ends (or starts, with a negative number of hours). The computation happens in the timezone of the given resource, or of the company without resource.

plan_days()

Same, with a number of working days. It returns the end of the first attendance of the last day (e.g. 12:00 for a schedule with a lunch break), not the end of that day.

_get_closest_work_time()

Returns the work interval start (or end) closest to a datetime, e.g. to snap a datetime typed by a user to the working hours.

_works_on_date() and _get_attendances_by_date()

Tell whether the calendar has attendances on a date, and which ones, taking recurrences of variable calendars into account.

_get_unusual_days()

Returns {'YYYY-MM-DD': bool}, True for days without work (weekends, public holidays). Calendar widgets use it to grey out days.

Example

monday_9am = datetime(2026, 10, 19, 9, 0, tzinfo=brussels)
calendar.plan_hours(10, monday_9am, resource=r2)
# datetime(2026, 10, 20, 11, 24, tzinfo=ZoneInfo('Europe/Brussels'))
# with compute_leaves, the public holiday and the sick leave of r2 are skipped
calendar.plan_hours(10, monday_9am, compute_leaves=True, resource=r2)
# datetime(2026, 10, 21, 16, 24, tzinfo=ZoneInfo('Europe/Brussels'))
calendar.plan_hours(2, datetime(2026, 10, 19, 9, 0), resource=r2)  # naive = UTC
# datetime(2026, 10, 19, 12, 0): 11:00 to 14:00 in Brussels, lunch break excluded

calendar._get_unusual_days(start, end)
# {'2026-10-19': False, '2026-10-20': True, '2026-10-21': False, '2026-10-22': False,
#  '2026-10-23': False, '2026-10-24': True}

Flexible calendars

A flexible calendar (calendar_type = 'undefined', see _is_flexible()) has no attendance, so the interval methods generate synthetic ones for the resources using it:

  • fully flexible (no hours target): a single interval covering the whole period;

  • with targets: one interval per day, of at most hours_per_day hours centered on 12:00, until hours_per_week is reached. Weeks are counted in blocks of 7 days starting at start_dt, not in calendar weeks.

Leaves of a flexible resource are extended to whole days.

注解

Whether a resource is flexible is decided from its own calendar at the start of the period (or the calendar of its employee’s version, with hr), not from the calendar the method is called on.

Example

flexible = env['resource.calendar'].create({
    'name': 'Flexible 20 hours/week',
    'calendar_type': 'undefined',
    'hours_per_week': 20,
    'hours_per_day': 6,
})
flexible.get_work_duration_data(
    datetime(2026, 10, 19, tzinfo=brussels), datetime(2026, 10, 26, tzinfo=brussels),
)
# {'days': 3.5, 'hours': 20.0}: 6 hours from Monday to Wednesday, 2 hours on Thursday

Pitfalls

  • Interval methods raise an assertion error with naive datetimes. Localize them first, e.g. datetime(2026, 10, 19, tzinfo=ZoneInfo(resource.tz)).

  • Calendar-level results (the False key, get_work_hours_count, …) only deduct global leaves. Use a resource to also take its own time off into account.

  • domain=None and domain=[] differ in leave methods: the first one only deducts absences, the second one also deducts leaves counted as working time. Domains must be lists.

  • In get_work_duration_data, domain filters the leaves when compute_leaves is set, and the attendances otherwise.

  • The payload of the intervals of a flexible calendar is a new, unsaved attendance holding only duration_hours: do not rely on its id or calendar_id.

  • Do not mutate the returned Intervals: the same object can be shared by several resources.

Extending

The following methods are designed to be overridden:

  • _work_intervals_batch() to alter the effective work intervals;

  • _get_reference_hours_per_day() to change the number of hours making a full day when converting hours to days;

  • _handle_flexible_leave_interval() to change how the leaves of flexible resources are stretched;

  • resource.calendar.attendance._is_work_period to exclude some attendances from the work time (hr_work_entry excludes the attendances whose work entry type counts as an absence).

Reference

Original definition from resource

model odoo.addons.resource.models.resource_calendar.ResourceCalendar[源代码]
_name = resource.calendar

Working schedule (“Working Time”) of resources. It holds:

  • attendance_ids: the resource.calendar.attendance lines defining when work is expected (per weekday for fixed calendars, per date, optionally recurring, for variable ones, none for undefined / flexible ones);

  • leave_ids: the resource.calendar.leaves linked to this calendar. A leave without resource_id is global (public holiday for every resource of the calendar), otherwise it only applies to that resource.

The computation API works on Intervals of (start, stop, records) triples, where start/stop are timezone-aware datetimes and records is the attendance or leave recordset that produced the interval. Batch methods return a dict {resource_id: Intervals} in which the key False holds the calendar-level result (no specific resource).

calendar_type: str
Required

Name

Calendar Type

Selection

fixed: Fixed variable: Variable undefined: Undefined

Default

fixed

  • Fixed: a weekly attendance pattern that repeats identically every week.
    • Variable: attendances set on specific dates rather than a repeating weekly pattern, such as a one-off schedule or a multi-week rotation.

    • Undefined: no predefined slots at all. The resource can work whenever it wants, optionally up to an hours target.

attendance_ids: Sequence[odoo.orm.commands.Command]
Name

Working Time

Comodel

resource.calendar.attendance

leave_ids: Sequence[odoo.orm.commands.Command]
Name

Time Off

Comodel

resource.calendar.leaves

global_leave_ids: Sequence[odoo.orm.commands.Command]
Name

Global Time Off

Comodel

resource.calendar.leaves

hours_per_week: float
Name

Hours per Week

hours_per_day: float
Name

Average Hour per Day

Average hours per day a resource is supposed to work with this calendar.

full_time_required_hours: float
Name

Full Time Equivalent

Number of hours to work on the company schedule to be considered as fulltime.

company_id: int
Name

Company

Comodel

res.company

_attendance_intervals_batch(start_dt, end_dt, resources_per_tz=None, domain=None)[源代码]

Return the theoretical work intervals generated by the attendance lines of this calendar between start_dt and end_dt, leaves NOT deducted.

Each interval is clipped to [start_dt, end_dt], expressed in the timezone of the resource (attendance hours are local times) and carries its single attendance record as payload (keep_distinct=True: two adjacent attendances stay two intervals). Duration-based attendances (no hour_from/hour_to) are placed contiguously, centered on 12:00.

Flexible resources get synthetic intervals instead, based on the calendar returned by resource._get_calendar_data_at (the resource’s own calendar, or the employee’s version calendar with hr), not on self:

  • fully flexible: a single interval covering the whole period;

  • flexible with hours targets: one interval per day of at most hours_per_day, centered on 12:00, until hours_per_week is reached in each 7-day block counted from start_dt (not calendar weeks).

Their payload is a new (unsaved) attendance holding only duration_hours.

self holds at most one calendar. It may be empty when resources_per_tz is given, but then only flexible resources get intervals.

参数
  • start_dt (datetime) – timezone-aware start of the period

  • end_dt (datetime) – timezone-aware end of the period

  • resources_per_tz (dict) – {ZoneInfo: resource.resource recordset}, as returned by resources._get_resources_per_tz(). Defaults to no resource, in the timezone of start_dt.

  • domain – optional domain on resource.calendar.attendance restricting the attendances used. When given, the flexible handling above is skipped.

返回

{resource_id: Intervals} for every resource of resources_per_tz, plus the key False (calendar-level, no resource) when self is set. With several timezones, the False entry is expressed in the last timezone of resources_per_tz.

返回类型

dict

_leave_intervals_batch(start_dt, end_dt, resources_per_tz=None, domain=None)[源代码]

Return the leave intervals (resource.calendar.leaves) overlapping the period, clipped to [start_dt, end_dt] and expressed in the timezone of each resource.

A resource gets its own leaves plus the global leaves (no resource_id) of its company; the calendar-level entry (key False) only gets global leaves. When self is set, only leaves of this calendar or without calendar are considered. Leaves of flexible resources go through _handle_flexible_leave_interval() (whole days by default). Overlapping leaves are merged, the payload being the union of the leave records.

参数
  • start_dt (datetime) – timezone-aware start of the period

  • end_dt (datetime) – timezone-aware end of the period

  • resources_per_tz (dict) – {ZoneInfo: resource.resource recordset}, see _attendance_intervals_batch()

  • domain (list) – domain (as a list) on resource.calendar.leaves. None means [('count_as', '=', 'absence')]; any other value, even [], replaces that default, so leaves counted as working time are then included.

返回

{resource_id: Intervals} for every resource of resources_per_tz, plus the key False when self is set or resources_per_tz is empty

返回类型

dict

_work_intervals_batch(start_dt, end_dt, resources_per_tz=None, domain=None, compute_leaves=True)[源代码]

Return the effective work intervals: attendance intervals minus leave intervals. This is the method to use (and the one to override, as hr_work_entry does) to know when resources actually work.

参数
  • start_dt (datetime) – timezone-aware start of the period

  • end_dt (datetime) – timezone-aware end of the period

  • resources_per_tz (dict) – {ZoneInfo: resource.resource recordset}, see _attendance_intervals_batch()

  • domain (list) – leave domain passed to _leave_intervals_batch() (None means leaves counted as absence). It does not filter attendances.

  • compute_leaves (bool) – when False, leaves are not deducted and the result equals _attendance_intervals_batch()

返回

{resource_id: Intervals}, with the key False for the calendar-level result when self is set or resources_per_tz is empty. Intervals are expressed in each resource’s timezone and carry attendance records.

返回类型

dict

_unavailable_intervals_batch(start_dt, end_dt, resources_per_tz=None, domain=None)[源代码]

Return the periods during which resources do not work: the complement of _work_intervals_batch() within [start_dt, end_dt], expressed in UTC (used by Gantt views to grey out unavailable time).

For a flexible resource (according to its own calendar), only its leaves are unavailable, and the resource has no key at all when it has no leave (callers treat that absence as “no unavailability”).

参数
返回

{resource_id: Intervals} in UTC, with the key False when self is set or resources_per_tz is empty

返回类型

dict

get_work_hours_count(start_dt, end_dt, compute_leaves=True, domain=None)[源代码]

Return the number of calendar-level work hours between two dates or datetimes (no resource: only global leaves are deducted).

Attendance hours are interpreted in the timezone of start_dt after conversion: dates and naive datetimes are put in the company timezone, aware datetimes keep their own timezone.

参数
  • start_dt – date (from 00:00 in the company timezone) or datetime (naive means UTC)

  • end_dt – date (until 23:59:59.999999 in the company timezone) or datetime (naive means UTC)

  • compute_leaves (bool) – deduct global leaves

  • domain (list) – leave domain, None means [('count_as', '=', 'absence')], see _leave_intervals_batch()

返回类型

float

get_work_duration_data(from_datetime, to_datetime, compute_leaves=True, domain=None)[源代码]

Return the calendar-level working duration of a period, in days and hours, only based on this calendar (no resource: only global leaves are deducted). Days are computed by _get_attendance_intervals_days_data().

Attendance hours are interpreted in the timezone of from_datetime (UTC if naive).

参数
  • from_datetime (datetime) – start of the period, naive means UTC

  • to_datetime (datetime) – end of the period, naive means UTC

  • compute_leaves (bool) – deduct global leaves

  • domain (list) – with compute_leaves, the leave domain (None means [('count_as', '=', 'absence')]); without it, a domain on resource.calendar.attendance filtering the attendances

返回

{'days': float, 'hours': float}

返回类型

dict

_get_attendance_intervals_days_data(attendance_intervals)[源代码]

Convert work intervals (typically the output of _work_intervals_batch() for one resource) into a duration in days and hours.

Intervals are split per calendar day (in their own timezone). For each day:

  • if this calendar has duration-based attendances on that day, the day counts for hours / sum(their duration_hours) (proportional);

  • otherwise it counts for 0.5 day if its hours are at most 3/4 of _get_reference_hours_per_day(), else for 1 day.

The payload of the intervals is ignored. self may be empty: then any day with hours counts as 1.

参数

attendance_intervals – iterable of (start, stop, records) with timezone-aware datetimes, e.g. an Intervals

返回

{'days': float, 'hours': float}, days rounded to 0.001

返回类型

dict

_get_reference_hours_per_day(day)[源代码]

Return the number of hours day is theoretically made of, used as the full-day reference by _get_attendance_intervals_days_data(). Defaults to the calendar’s average hours_per_day; overridden by hr_work_entry to include attendances counted as absence.

参数

day (date) – the day to evaluate

返回类型

float

plan_hours(hours, day_dt, compute_leaves=False, domain=None, resource=None)[源代码]

Return the datetime reached after working hours hours from day_dt according to this calendar (going backwards if hours is negative). With hours=0, return day_dt if it is within work time, else the start of the next work interval.

Computation happens in the timezone of resource (company timezone without resource), by windows of 14 days, for at most 100 windows.

参数
  • hours (float) – number of work hours to plan, negative to plan backwards

  • day_dt (datetime) – starting point; naive means UTC

  • compute_leaves (bool) – deduct leaves (those of resource and global ones); without it, the calendar-level attendances are used and resource only gives the timezone

  • domain (list) – leave domain, see _leave_intervals_batch()

  • resource – optional resource.resource record

返回

the resulting datetime, in the timezone of day_dt (naive UTC if day_dt is naive), or False if not found within the search range

返回类型

datetime | bool

plan_days(days, day_dt, compute_leaves=False, domain=None)[源代码]

Return the end of the first work interval of the days-th work day counted from day_dt (the day of day_dt included if it has work time after day_dt), or, for a negative days, the start of the last work interval of the abs(days)-th work day counted backwards. days=0 returns day_dt.

Beware: with several attendances per day (e.g. a lunch break), the result is the end of the morning attendance of the last day, not the end of that day.

Calendar-level only (no resource, only global leaves), computed in the company timezone by windows of 14 days, for at most 100 windows.

参数
  • days (int) – number of work days to plan, negative to plan backwards

  • day_dt (datetime) – starting point; naive means UTC

  • compute_leaves (bool) – deduct global leaves

  • domain (list) – leave domain, see _leave_intervals_batch()

返回

the resulting datetime, in the timezone of day_dt (naive UTC if day_dt is naive), or False if not found within the search range

返回类型

datetime | bool

_get_closest_work_time(dt, match_end=False, resource=None, search_range=None, compute_leaves=True)[源代码]

Return the work interval boundary closest to dt within the search range: the closest interval start, or the closest interval end when match_end is set.

Work intervals come from _work_intervals_batch() for resource, in the resource timezone. Without resource, the calendar-level intervals are used and the attendance hours are interpreted in UTC.

参数
  • dt (datetime) – timezone-aware reference datetime

  • match_end (bool) – look for interval ends instead of interval starts

  • resource – resource.resource record, or None

  • search_range – (start, end) timezone-aware datetimes; defaults to the whole day of dt in the resource timezone

  • compute_leaves (bool) – deduct leaves from the work intervals

返回

the closest boundary (in the resource timezone), or None if dt is outside the search range or there is no work interval in it

返回类型

datetime | None

引发

ValueError – if dt or search_range are naive

_works_on_date(date)[源代码]

Return whether this calendar has a work attendance (see resource.calendar.attendance._is_work_period) on date. Always True for flexible calendars. Leaves are not considered.

参数

date (date) – the day to check

返回类型

bool

_get_attendances_by_date(date_from, date_to, domain=None)[源代码]

Return the attendances of this calendar applying on each day of the period.

  • Undated attendances (fixed calendars) apply on every day matching their dayofweek.

  • Dated attendances (variable calendars) apply on their date and, when recurring, on every occurrence of their recurrence rule up to recurrency_until, except excluded occurrences.

参数
  • date_from (date) – first day of the period (included)

  • date_to (date) – last day of the period (included)

  • domain – optional domain on resource.calendar.attendance

返回

{date: resource.calendar.attendance recordset} with one key per day of the period, possibly mapped to an empty recordset (a defaultdict)

返回类型

dict

_get_unusual_days(start_dt, end_dt, company_id=False, resource=None)[源代码]

Tell, for each day between start_dt and end_dt, whether it is an “unusual” day, i.e. a day without work (weekend, public holiday…). Used by calendar and date picker widgets to grey out days.

Days are evaluated with the calendar-level work intervals (global leaves deducted), in the timezone of start_dt. For a flexible resource, a day is unusual only if the resource has a leave on it. Only leaves counted as absence are considered: a leave counted as working time (e.g. a training) does not make a day unusual.

参数
  • start_dt (datetime) – start of the period; naive means UTC

  • end_dt (datetime) – end of the period (its day included); naive means UTC

  • company_id – optional res.company record restricting the leaves to that company or to no company

  • resource – optional resource.resource record, only used for flexible ones

返回

{'YYYY-MM-DD': bool}, True for unusual days

返回类型

dict

_is_flexible()[源代码]

Return whether this calendar is flexible, i.e. of type undefined: it has no attendance lines and the resource may work whenever it wants, optionally up to the hours_per_week / hours_per_day targets (see _is_fully_flexible()).

_is_fully_flexible()[源代码]

Return whether this calendar is flexible (see _is_flexible()) and has no hours target either (hours_per_week and hours_per_day both zero). A fully flexible resource is considered working during the whole requested period.

_handle_flexible_leave_interval(dt0, dt1, leave)[源代码]

Hook adapting the bounds of a resource-specific leave of a flexible resource. By default, the leave is extended to whole days: from 00:00 on the day of dt0 to 23:59:59.999999 on the day of dt1, in their timezone.

参数
  • dt0 (datetime) – leave start, localized in the resource timezone

  • dt1 (datetime) – leave end, localized in the resource timezone

  • leave – the resource.calendar.leaves record

返回

the adapted (dt0, dt1)

返回类型

tuple

Original definition from resource

model odoo.addons.resource.models.resource_calendar_attendance.ResourceCalendarAttendance[源代码]
_name = resource.calendar.attendance
calendar_id: int
Required

Name

Resource’s Calendar

Comodel

resource.calendar

dayofweek: str
Required

Name

Day of Week

Selection

0: Monday 1: Tuesday 2: Wednesday 3: Thursday 4: Friday 5: Saturday 6: Sunday

hour_from: float
Required

Name

Work from

Default

0

Start and End time of working. A specific value of 24:00 is interpreted as 23:59:59.999999.

hour_to: float
Required

Name

Work to

Default

0

duration_hours: float
Name

Hours

day_period: str
Name

Day Period

Readonly

this field is not supposed to/cannot be set manually

Selection

morning: Morning afternoon: Afternoon full_day: Full Day

date: datetime.date
Name

Date

recurrency: bool
Name

Recurrency

recurrency_type: str
Name

Recurrency Type

Selection

days: Days weeks: Weeks

Default

weeks

recurrency_interval: int
Name

Interval

Default

1

Number of days or weeks between each occurrence.

_is_work_period()[源代码]

Return whether this attendance counts as work time, e.g. for hours_per_week and days_per_week. Always True here; hr_work_entry returns False for attendances whose work entry type counts as absence.

Original definition from resource

model odoo.addons.resource.models.resource_calendar_leaves.ResourceCalendarLeaves[源代码]
_name = resource.calendar.leaves
date_from: datetime.datetime
Required

Name

Start Date

date_to: datetime.datetime
Required

Name

End Date

resource_id: int
Name

Resource

Comodel

resource.resource

If empty, this is a generic time off for the company. If a resource is set, the time off is only for this resource

calendar_id: int
Name

Working Hours

Comodel

resource.calendar

company_id: int
Name

Company

Readonly

this field is not supposed to/cannot be set manually

Comodel

res.company

count_as: str
Name

Count As

Selection

absence: Absence working_time: Working Time

Default

absence

Whether this should be computed as a time off or as work time (eg: formation)