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.
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¶
- 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
- member_ids: Sequence[odoo.orm.commands.Command]¶
- Name
Members
- Readonly
this field is not supposed to/cannot be set manually
- Comodel
- master_department_id: int¶
- Name
Master Department
- Readonly
this field is not supposed to/cannot be set manually
- Comodel
- write(vals)[原始碼]¶
Write on departments; a new
manager_idbecomes the manager of the department’s employees.
- _update_employee_manager(manager_id)[原始碼]¶
Set
manager_idasparent_idof the department members who were managed by the previous manager.Only direct members of each department whose
parent_idis the department’s current manager are updated (not child departments, and not employees with another manager); the new manager is skipped.
Original definition from hr¶
- model odoo.addons.hr.models.hr_job.HrJob[原始碼]¶
- _name = hr.job¶
- employee_ids: Sequence[odoo.orm.commands.Command]¶
- Name
Employees
- Comodel
Original definition from hr¶
Original definition from hr¶
Original definition from hr¶
Original definition from hr¶
Original definition from hr¶
Original definition from hr¶
- model odoo.addons.hr.models.hr_employee_departure.HrEmployeeDeparture[原始碼]¶
- _name = hr.employee.departure¶
- 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_idis set andcontract_date_endbecomes the departure date (only if the version has a contract). The previous contract end date is saved inlast_contract_date_end(restored byhr.employee.action_cancel_departure). The employee is archived later, byaction_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 withdate_versionafter the departure date are deleted, employees are archived (hr.employee.action_archive) andapply_dateis 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
- 回傳型別
- 引發
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_dateis today or earlier, or, withoutaction_date, whosedeparture_dateis before today; seeaction_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 ofselfby default).Override to exclude departures from archival, e.g. per country rules (see
l10n_be_hr_payroll).- 回傳型別
hr.employee.departure