Organization and configuration

Besides employees and versions, hr defines the models describing the organization (departments, job positions, work locations), the classification of employees (tags, employee types, salary structure types), the departures, and a mixin for models linked to employees.

Unless stated otherwise, these models are readable by every internal user and managed by HR officers (hr.group_hr_user); see Access rights.

Departments

A department (hr.department) belongs to a company and may have a parent department (parent_id, with _parent_store): complete_name is the full path (R&D / Backend) and master_department_id the root of the tree. member_ids are the employees whose current version has the department (the department is a version field), and manager_id is an employee.

Setting a new manager on a department (write()) makes it the manager (parent_id) of the department members who were managed by the previous manager (_update_employee_manager()); members of child departments and members with another manager are not changed.

Besides the HR officers, the manager of a department can update it, and so can the employees the manager reports to (directly or indirectly).

alice = env['hr.employee'].create({'name': 'Alice'})
bob = env['hr.employee'].create({'name': 'Bob'})
rd = env['hr.department'].create({'name': 'R&D'})
backend = env['hr.department'].create({
    'name': 'Backend', 'parent_id': rd.id, 'manager_id': alice.id,
})
dev = env['hr.employee'].create({
    'name': 'Dev', 'department_id': backend.id, 'parent_id': alice.id,
})
backend.complete_name, backend.master_department_id.name  # ('R&D / Backend', 'R&D')
rd.get_children_department_ids().mapped('name')  # ['Backend', 'R&D']

backend.manager_id = bob
dev.parent_id.name  # 'Bob'

member_of_department (on versions and public employees) is a searchable flag matching the employees of the current user’s department and its child departments.

Job positions

A job position (hr.job) is unique per name, department and company. Employees reference it in their version (job_id); job_title is a free text computed from it and editable. no_of_employee counts the employees in the position, no_of_recruitment is the recruitment target and expected_employees their sum. The recruitment application extends the model heavily.

Work locations

A work location (hr.work.location) is a place with a type (location_type: home, office or other) and an address. The version holds the main work location (work_location_id); the employee holds a default location for each weekday (monday_location_id, …, sunday_location_id), and hr.employee.location records an exceptional location for a given date (one per employee and date). work_location_name and work_location_type on the employee give today’s location. A location used by employees cannot be deleted.

Tags, employee types and salary structure types

hr.employee.category

Tags of the employees (category_ids on the employee, not time-dependent). Names are unique.

hr.employee.type

The kind of employment (Employee, Student, Intern, …), referenced by the version (employee_type_id, HR administrators only). It can be restricted to a country (country_id); code defaults to the name and is meant to be used by localizations.

hr.payroll.structure.type

Defined in hr although it is mostly a payroll concept: a name, a country and a default working schedule (default_resource_calendar_id). The version references it (structure_type_id, HR administrators only); by default, the first structure type of the company’s country, or one without country. hr_payroll adds the salary structures and the payroll configuration to it (see Salary structures and rules).

Departures and departure reasons

hr.employee.departure records the end of the collaboration of an employee: the reason (departure_reason_id, required), the dismissal date (start of the departure process), the departure date (equal to the dismissal date in hr, computed by _compute_departure_date() so that localizations can add a notice period), the date at which the employee is archived (action_date) and the date at which the departure was applied (apply_date). How it ends the contract and archives the employee is explained in Departure.

hr.departure.reason lists the reasons, optionally per country. The default reasons (Fired, Resigned, Retired) cannot be deleted.

The hr.mixin mixin

Writing a many2many field requires read access to its comodel. Users without access to hr.employee (see Public employees and access rights) could therefore not set a many2many field to employees, e.g. the cashiers of a point of sale. A model inheriting hr.mixin gets read access to all employees during its own create and write (through a private context marker checked by hr.employee._access_domain).

class PosConfig(models.Model):
    _inherit = ['hr.mixin', 'pos.config']

    cashier_employee_ids = fields.Many2many('hr.employee', ...)

Reference

Original definition from hr

model odoo.addons.hr.models.hr_department.HrDepartment[原始碼]
_name = hr.department
name: str
Required

Name

Department Name

complete_name: str
Name

Complete Name

Readonly

this field is not supposed to/cannot be set manually

Store

this field is there only for technical reasons

parent_id: int
Name

Parent Department

Comodel

hr.department

manager_id: int
Name

Manager

Comodel

hr.employee

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

Members

Readonly

this field is not supposed to/cannot be set manually

Comodel

hr.employee

master_department_id: int
Name

Master Department

Readonly

this field is not supposed to/cannot be set manually

Comodel

hr.department

company_id: int
Name

Company

Comodel

res.company

write(vals)[原始碼]

Write on departments; a new manager_id becomes the manager of the department’s employees.

See _update_employee_manager().

_update_employee_manager(manager_id)[原始碼]

Set manager_id as parent_id of the department members who were managed by the previous manager.

Only direct members of each department whose parent_id is the department’s current manager are updated (not child departments, and not employees with another manager); the new manager is skipped.

參數

manager_id (int or bool) – id of the new manager (hr.employee), or False

get_children_department_ids()[原始碼]

Return the departments and all their descendants (child_of), self included.

回傳型別

hr.department

get_department_hierarchy()[原始碼]

Return the department with its parent and direct children, for the hierarchy widget.

回傳

{'parent': node or False, 'self': node, 'children': [node, ...]} where a node is {'id', 'name', 'employees'} (employees being total_employee); {} for an empty recordset

回傳型別

dict

Original definition from hr

model odoo.addons.hr.models.hr_job.HrJob[原始碼]
_name = hr.job
name: str
Required

Name

Job Position

department_id: int
Name

Department

Comodel

hr.department

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

Employees

Comodel

hr.employee

no_of_employee: int
Name

Current Number of Employees

Readonly

this field is not supposed to/cannot be set manually

Store

this field is there only for technical reasons

Number of employees currently occupying this job position.

no_of_recruitment: int
Name

Target

Default

1

Number of new employees you expect to recruit.

expected_employees: int
Name

Total Forecasted Employees

Readonly

this field is not supposed to/cannot be set manually

Store

this field is there only for technical reasons

Expected number of employees for this job position after new recruitment.

Original definition from hr

model odoo.addons.hr.models.hr_work_location.HrWorkLocation[原始碼]
_name = hr.work.location
name: str
Required

Name

Work Location

location_type: str
Required

Name

Location Type

Selection

home: Home office: Office other: Other

Default

office

address_id: int
Name

Work Address

Comodel

res.partner

Original definition from hr

model odoo.addons.hr.models.hr_employee_location.HrEmployeeLocation[原始碼]
_name = hr.employee.location
employee_id: int
Required

Name

Employee

Comodel

hr.employee

date: datetime.date
Name

Date

work_location_id: int
Required

Name

Location

Comodel

hr.work.location

Original definition from hr

model odoo.addons.hr.models.hr_employee_category.HrEmployeeCategory[原始碼]
_name = hr.employee.category
name: str
Required

Name

Tag Name

Original definition from hr

model odoo.addons.hr.models.hr_employee_type.HrEmployeeType[原始碼]
_name = hr.employee.type
name: str
Required

Name

Name

code: str
Name

Code

country_id: int
Name

Country

Comodel

res.country

Possible_values

odoo/addons/base/data/res_country_data.xml

Original definition from hr

model odoo.addons.hr.models.hr_payroll_structure_type.HrPayrollStructureType[原始碼]
_name = hr.payroll.structure.type
name: str
Name

Salary Structure Type

country_id: int
Name

Country

Comodel

res.country

Possible_values

odoo/addons/base/data/res_country_data.xml

default_resource_calendar_id: int
Name

Working Hours

Comodel

resource.calendar

Original definition from hr

model odoo.addons.hr.models.hr_employee_departure.HrEmployeeDeparture[原始碼]
_name = hr.employee.departure
employee_id: int
Required

Name

Employee

Comodel

hr.employee

departure_reason_id: int
Required

Name

End Reason

Comodel

hr.departure.reason

dismissal_date: datetime.date
Required

Name

Dismissal Date

Default

2026-11-03

Date at which the departure process starts. Differs from the actual departure date in case of a notice period.

departure_date: datetime.date
Name

Departure Date

Date at which the departure actually takes place.

action_date: datetime.date
Name

Archive Employee On

Readonly

this field is not supposed to/cannot be set manually

Date at which the departure actually takes place.

apply_date: datetime.date
Name

Apply Date

Readonly

this field is not supposed to/cannot be set manually

last_contract_date_end: datetime.date
Name

Last Contract Date End

create(vals_list)[原始碼]

Create departures and end the employee’s contract on the departure date.

On all versions of the contract in effect on departure_date, departure_id is set and contract_date_end becomes the departure date (only if the version has a contract). The previous contract end date is saved in last_contract_date_end (restored by hr.employee.action_cancel_departure). The employee is archived later, by action_register().

action_register()[原始碼]

Apply the departures: archive the employees (and their users) and delete later versions.

For the departures returned by _get_departures_to_archive(): versions with date_version after the departure date are deleted, employees are archived (hr.employee.action_archive) and apply_date is set to today. A user is archived only if all its active employees are departing.

回傳

a notification action listing archived / kept users, or a window close action

回傳型別

dict

引發

ValidationError – if a departure’s apply date is in the future

_cron_apply_departure()[原始碼]

Apply the pending departures whose date is reached (daily cron).

Targets departures not applied yet whose action_date is today or earlier, or, without action_date, whose departure_date is before today; see action_register().

_compute_departure_date()[原始碼]

Compute the departure date, equal to the dismissal date by default.

Override point for localizations with a notice period.

_get_departures_to_archive()[原始碼]

Return the departures that action_register() should apply (all of self by default).

Override to exclude departures from archival, e.g. per country rules (see l10n_be_hr_payroll).

回傳型別

hr.employee.departure

Original definition from hr

model odoo.addons.hr.models.hr_departure_reason.HrDepartureReason[原始碼]
_name = hr.departure.reason
name: str
Required

Name

Reason

country_id: int
Name

Country

Comodel

res.country

Possible_values

odoo/addons/base/data/res_country_data.xml

Original definition from hr

model odoo.addons.hr.models.hr_mixin.HrMixin[原始碼]
_name = hr.mixin