Resource
resource · odoo/odoo
-
Security25/25No findings
-
Activity25/25Human commit this month
-
Required by25/2510 modules depend on it
-
Maturity25/25In 15 Odoo series since 6.1
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
- Raw `cr.execute()` INSERT/UPDATE/DELETE bypasses the ORM (no compute/constrains/tracking/mail): `SELECT id FROM resource_calendar WHERE id IN %s ORDER BY id FOR NO KEY UPDATE` - re-check the table/column names still match after upgrading. migration-raw-sql-write · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
Module for resource management.
A resource represent something that can be scheduled (a developer on a task or a work center on manufacturing orders). This module manages a resource calendar associated to every resource. It also manages the leaves of every resource.
Dependencies
- Odoo dependencies
- Python dependencies
- None
- System dependencies
- None
- Required by
- base_automation, crm, digest, hr_holidays, mrp, point_of_sale, project, resource_mail, stock_warehouse_calendar, test_resource
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 15
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
resource_calendar_form |
resource.calendar.form | resource.calendar | form | New |
resource_calendar_leave_form |
resource.calendar.leaves.form | resource.calendar.leaves | form | New |
resource_calendar_leave_tree |
resource.calendar.leaves.list | resource.calendar.leaves | list | New |
resource_resource_form |
resource.resource.form | resource.resource | form | New |
resource_resource_tree |
resource.resource.list | resource.resource | list | New |
view_company_form_inherit_resource |
res.company.form.inherit.resource | res.company | form | Inherits base.view_company_form |
view_resource_calendar |
resource.calendar.leaves.calendar | resource.calendar.leaves | calendar | New |
view_resource_calendar_attendance_calendar |
resource.calendar.attendance.calendar | resource.calendar.attendance | calendar | New |
view_resource_calendar_attendance_form |
resource.calendar.attendance.form | resource.calendar.attendance | form | New |
view_resource_calendar_attendance_tree |
resource.calendar.attendance.list | resource.calendar.attendance | list | New |
view_resource_calendar_leaves_search |
resource.calendar.leaves.search | resource.calendar.leaves | search | New |
view_resource_calendar_multi_create_form |
resource.calendar.multi.create.form | resource.calendar.attendance | form | New |
view_resource_calendar_search |
resource.calendar.search | resource.calendar | search | New |
view_resource_calendar_tree |
resource.calendar.list | resource.calendar | list | New |
view_resource_resource_search |
resource.resource.search | resource.resource | search | New |
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 7
-
resource_calendar_idMany2one → resource.calendarondelete='restrict' args: 'resource.calendar', 'Default Working Hours' -
resource_calendar_idsOne2many → resource.calendarargs: 'resource.calendar', 'company_id', 'Working Hours' -
tzSelectioncompute='_compute_tz'readonly=Falsestore=Truestring='Timezone' args: _tz_get
-
create(self, vals_list)@api.model_create_multi
-
resource_calendar_idMany2one → resource.calendarreadonly=Falserelated='resource_ids.calendar_id' args: 'resource.calendar', 'Default Working Hours' -
resource_idsOne2many → resource.resourceargs: 'resource.resource', 'user_id', 'Resources'
No public methods.
-
activeBooleandefault=Truehelp='If the active field is set to false, it will allow you to hide the Working Time without removing it.' args: 'Active' -
attendance_idsOne2many → resource.calendar.attendancecompute='_compute_attendance_ids'copy=Trueprecompute=Truereadonly=Falsestore=True args: 'resource.calendar.attendance', 'calendar_id', 'Working Time' -
calendar_typeSelectiondefault='fixed'help='\n - Fixed: a weekly attendance pattern that repeats identically every week.\n - Variable: attendances set on specific dates rather than a repeating weekly pattern, such as a one-off schedule or a multi-week rotation.\n - Undefined: no predefined slots at all. The resource can work whenever it wants, optionally up to an hours target.\n 'required=Truestring='Calendar Type' args: [('fixed', 'Fixed'), ('variable', 'Variable'), ('undefined', 'Undefined')] -
company_idMany2one → res.companydefault=<expr>domain=<expr>index='btree_not_null' args: 'res.company', 'Company' -
country_codeChardepends=['country_id']related='country_id.code' -
country_idMany2onerelated='company_id.country_id' -
days_per_weekFloatcompute='_compute_days_per_week'copy=Falsedigits=(10, 5)readonly=Falsestore=True args: 'Days per Week' -
full_time_required_hoursFloatcompute='_compute_full_time_required_hours'help='Number of hours to work on the company schedule to be considered as fulltime.'readonly=Falsestore=Truestring='Full Time Equivalent' -
global_leave_idsOne2many → resource.calendar.leavescompute='_compute_global_leave_ids'domain=[('resource_id', '=', False)]readonly=Falsestore=True args: 'resource.calendar.leaves', 'calendar_id', 'Global Time Off' -
hours_per_dayFloatcompute='_compute_hours_per_day'copy=Falsedigits=(10, 5)help='Average hours per day a resource is supposed to work with this calendar.'readonly=Falsestore=True args: 'Average Hour per Day' -
hours_per_weekFloatcompute='_compute_hours_per_week'copy=Falsedigits=(10, 5)readonly=Falsestore=Truestring='Hours per Week' -
is_fulltimeBooleancompute='_compute_is_fulltime'string='Is Full Time' -
leave_idsOne2many → resource.calendar.leavesargs: 'resource.calendar.leaves', 'calendar_id', 'Time Off' -
nameCharrequired=True -
reference_calendar_idMany2one → resource.calendarcheck_company=Truehelp='Reference working hours used to compute the full-time equivalent.'index='btree_not_null'string='Reference Calendar' args: 'resource.calendar' -
work_resources_countIntegercompute='_compute_work_resources_count' args: 'Work Resources count' -
work_time_rateFloatcompute='_compute_work_time_rate'help='Work time rate versus full time working schedule, should be between 0 and 100 %.'store=Truestring='Work Time Rate'
-
copy_data(self, default=None) -
create(self, vals_list)@api.model_create_multi -
default_get(self, fields)@api.model -
get_attendances(self, date_from, date_to, fields_to_fetch, domain=None)Public (RPC) variant of :meth:`_get_attendances_by_date` used by the calendar editor: return each attendance occurring in the period once, read with ``fields_to_fetch``. :param date_from: first day, as a ``date`` or a ``'YYYY-MM-DD'`` string :param date_to: last day, as a ``date`` or a ``'YYYY-MM-DD'`` string :param list fields_to_fetch: field names to read :param domain: optional domain on ``resource.calendar.attendance`` :return: list of dicts with the read values, plus ``'date'`` (first occurrence in the period) and ``'other_dates'`` (list of the next occurrences) :rtype: list -
get_work_duration_data(self, 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 :meth:`_get_attendance_intervals_days_data`. Attendance hours are interpreted in the timezone of ``from_datetime`` (UTC if naive). :param datetime from_datetime: start of the period, naive means UTC :param datetime to_datetime: end of the period, naive means UTC :param bool compute_leaves: deduct global leaves :param list domain: with ``compute_leaves``, the leave domain (``None`` means ``[('count_as', '=', 'absence')]``); without it, a domain on ``resource.calendar.attendance`` filtering the attendances :return: ``{'days': float, 'hours': float}`` :rtype: dict -
get_work_hours_count(self, 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. :param start_dt: ``date`` (from 00:00 in the company timezone) or ``datetime`` (naive means UTC) :param end_dt: ``date`` (until 23:59:59.999999 in the company timezone) or ``datetime`` (naive means UTC) :param bool compute_leaves: deduct global leaves :param list domain: leave domain, ``None`` means ``[('count_as', '=', 'absence')]``, see :meth:`_leave_intervals_batch` :rtype: float -
is_calendar_referenced(self)Return whether any stored many2one field of a non-abstract model (other than the ``resource.calendar*`` models) points to this calendar. Searches as superuser. -
plan_days(self, 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. :param int days: number of work days to plan, negative to plan backwards :param datetime day_dt: starting point; naive means UTC :param bool compute_leaves: deduct global leaves :param list domain: leave domain, see :meth:`_leave_intervals_batch` :return: 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 :rtype: datetime | bool -
plan_hours(self, 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. :param float hours: number of work hours to plan, negative to plan backwards :param datetime day_dt: starting point; naive means UTC :param bool compute_leaves: deduct leaves (those of ``resource`` and global ones); without it, the calendar-level attendances are used and ``resource`` only gives the timezone :param list domain: leave domain, see :meth:`_leave_intervals_batch` :param resource: optional ``resource.resource`` record :return: 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 :rtype: datetime | bool -
write(self, vals)
-
calendar_idMany2one → resource.calendarindex=Trueondelete='cascade'required=Truestring="Resource's Calendar" args: 'resource.calendar' -
calendar_typeSelectionreadonly=Truerelated='calendar_id.calendar_type' -
dateDate -
day_periodSelectioncompute='_compute_day_period'store=True args: [('morning', 'Morning'), ('afternoon', 'Afternoon'), ('full_day', 'Full Day')] -
dayofweekSelectioncompute='_compute_dayofweek'index=Trueprecompute=Truereadonly=Falserequired=Truestore=True args: [('0', 'Monday'), ('1', 'Tuesday'), ('2', 'Wednesday'), ('3', 'Thursday'), ('4', 'Friday'), ('5', 'Saturday'), ('6', 'Sunday')], 'Day of Week' -
duration_basedBooleancompute='_compute_duration_based'precompute=Truestore=True -
duration_hoursFloatcompute='_compute_duration_hours'readonly=Falsestore=Truestring='Hours' -
hour_fromFloatcompute='_compute_hours'default=0help='Start and End time of working.\nA specific value of 24:00 is interpreted as 23:59:59.999999.'index=Trueprecompute=Truereadonly=Falserequired=Truestore=Truestring='Work from' -
hour_toFloatcompute='_compute_hours'default=0precompute=Truereadonly=Falserequired=Truestore=Truestring='Work to' -
recurrencyBoolean -
recurrency_countIntegerdefault=1string='Number of Repetitions' -
recurrency_end_typeSelectiondefault='forever'string='Recurrence End Condition' args: [('forever', 'Forever'), ('times', 'Occurrences'), ('date', 'Until')] -
recurrency_excluded_occurencesJson -
recurrency_intervalIntegerdefault=1help='Number of days or weeks between each occurrence.'string='Interval' -
recurrency_typeSelectiondefault='weeks' args: [('days', 'Days'), ('weeks', 'Weeks')] -
recurrency_untilDatecompute='_compute_recurrency_until'precompute=Truereadonly=Falsestore=Truestring='Recurrence End Date' -
sequenceIntegerdefault=10help='Gives the sequence of this line when displaying the resource calendar.'
-
create_ad_hoc(self, date, changes)Modify a single occurrence of this recurring attendance: exclude the occurrence at ``date`` and create a non-recurring copy of the attendance updated with ``changes``. :param str date: the occurrence to replace, as ``'YYYY-MM-DD'`` :param dict changes: values overriding the copied ones (typically including ``date``) :return: the new attendance -
create_new_recurrency(self, date, changes)Modify this recurring attendance from ``date`` onwards: stop the current recurrence the day before ``date`` and create a recurring copy updated with ``changes``. :param str date: first occurrence to change, as ``'YYYY-MM-DD'`` :param dict changes: values overriding the copied ones (typically including ``date``) :return: the new attendance -
exclude_multiple_occurences(self, dates)Call :meth:`exclude_occurence` for each of ``dates`` (``'YYYY-MM-DD'`` strings) on each attendance of ``self``. -
exclude_occurence(self, date)Remove one occurrence of this recurring attendance (calendar editor action). Excluding the first occurrence moves ``date`` to the next non-excluded occurrence, or deletes the attendance when there is none left. :param str date: the occurrence to exclude, as ``'YYYY-MM-DD'`` -
stop_recurrency(self, date)End this recurring attendance the day before ``date`` (``'YYYY-MM-DD'``).
-
calendar_idMany2one → resource.calendarcheck_company=Truecompute='_compute_calendar_id'domain="[('company_id', 'in', [company_id, False])]"index=Truereadonly=Falsestore=True args: 'resource.calendar', 'Working Hours' -
company_idMany2one → res.companycompute='_compute_company_id'default=<expr>readonly=Truestore=Truestring='Company' args: 'res.company' -
count_asSelectiondefault='absence'help='Whether this should be computed as a time off or as work time (eg: formation)' args: [('absence', 'Absence'), ('working_time', 'Working Time')] -
date_fromDatetimerequired=True args: 'Start Date' -
date_toDatetimecompute='_compute_date_to'readonly=Falserequired=Truestore=True args: 'End Date' -
nameCharargs: 'Reason' -
resource_idMany2one → resource.resourcehelp='If empty, this is a generic time off for the company. If a resource is set, the time off is only for this resource'index=True args: 'resource.resource', 'Resource'
-
check_dates(self)@api.constrains('date_from', 'date_to') -
default_get(self, fields)@api.model
-
company_idMany2one → res.companydefault=<expr>index=Trueprecompute=Truereadonly=Falserelated='resource_id.company_id'store=True args: 'res.company', 'Company' -
resource_calendar_idMany2one → resource.calendardefault=<expr>index=Truereadonly=Falserelated='resource_id.calendar_id'store=True args: 'resource.calendar', 'Working Hours' -
resource_idMany2one → resource.resourcebypass_search_access=Trueindex=Trueondelete='restrict'required=True args: 'resource.resource', 'Resource' -
tzSelectionhelp='This field is used in order to define in which timezone the resources will work.'readonly=Falserelated='resource_id.tz'string='Timezone'
-
copy_data(self, default=None) -
create(self, vals_list)@api.model_create_multi
-
activeBooleandefault=Truehelp='If the active field is set to False, it will allow you to hide the resource record without removing it.' args: 'Active' -
avatar_128Imagecompute='_compute_avatar_128'compute_sudo=True -
calendar_idMany2one → resource.calendardefault=<expr>domain="[('company_id', '=', company_id)]"help='Define the working schedule of the resource. Assign a flexible calendar for fully flexible working hours.'required=Truestring='Working Time' args: 'resource.calendar' -
colorIntegerdefault=_default_color -
company_idMany2one → res.companydefault=<expr>string='Company' args: 'res.company' -
emailCharrelated='user_id.email' -
hours_per_dayFloatreadonly=Truerelated='calendar_id.hours_per_day'string='Hours per Day' -
hours_per_weekFloatreadonly=Truerelated='calendar_id.hours_per_week'string='Hours per Week' -
nameCharrequired=True -
phoneCharrelated='user_id.phone' -
resource_typeSelectiondefault='user'required=Truestring='Type' args: [('user', 'Human'), ('material', 'Material')] -
shareBooleanrelated='user_id.share' -
time_efficiencyFloatdefault=100help='This field is used to calculate the expected duration of a work order at this work center. For example, if a work order takes one hour and the efficiency factor is 100%, then the expected duration will be one hour. If the efficiency factor is 200%, however the expected duration will be 30 minutes.'required=True args: 'Efficiency Factor' -
tzSelectiondefault=<expr>required=Truestring='Timezone' args: _tz_get -
user_idMany2one → res.usershelp='Related user name for the resource to manage its access.'index='btree_not_null'string='User' args: 'res.users'
-
create(self, vals_list)@api.model_create_multi -
default_get(self, fields)@api.model -
write(self, vals)
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…