Human Resources¶
The hr module (Employees application) defines the employees, their data over time and their
contracts, and the organization of the company (departments, job positions, work locations). It
is the base of every HR application: Time Off, Attendances, Payroll, Appraisals, Recruitment,
Expenses, Planning, …
It relies on the resource module for the working schedules and the time computations.
Models overview¶
![digraph hr {
rankdir=LR;
node [shape=box, style=rounded, fontname="sans-serif", fontsize=10];
edge [fontname="sans-serif", fontsize=9];
employee [label="hr.employee\n(the person in a company)"];
version [label="hr.version\n(data over time, contract)"];
public [label="hr.employee.public\n(SQL view, public data)"];
resource [label="resource.resource\n(calendar, timezone)"];
user [label="res.users"];
partner [label="res.partner\n(work contact)"];
departure [label="hr.employee.departure"];
department [label="hr.department"];
job [label="hr.job"];
employee -> version [label="version_ids\nversion_id (_inherits)"];
public -> employee [label="employee_id\n(same id)"];
employee -> resource [label="resource_id"];
employee -> user [label="user_id"];
employee -> partner [label="work_contact_id"];
employee -> employee [label="parent_id"];
version -> department [label="department_id"];
version -> job [label="job_id"];
version -> departure [label="departure_id"];
}](../../../_images/graphviz-ed494ad16be84ddc324915008c118c31c0df02ca.png)
- hr.employee
A person working for a company. It holds the data that does not change over time and links to a resource (working schedule, timezone), a work contact and optionally a user.
- hr.version
Employee Record: the data of an employee that changes over time (job, department, working schedule, wage, private address, …), effective from a date. The contract is carried by the contract dates of the versions. A version without employee is a contract template.
- hr.employee.public
A read-only SQL view exposing the non-sensitive data of the employees to every internal user.
- hr.department, hr.job, hr.work.location, …
The organization and the configuration: departments, job positions, work locations, employee tags and types, salary structure types, departures and departure reasons.
- hr.leave, hr.leave.allocation (
hr_holidays) Time off requests and their approval, allocations, balances and accrual plans. Time off types are work entry types.
- hr.attendance (
hr_attendance) Check-ins and check-outs of the employees, their worked and overtime hours.
Employees and versions in short¶
hr.employeeinheritshr.versionby delegation (_inherits): every version field can be read and written on the employee, e.g.employee.wage.The version read and written is
version_id: the current version (current_version_id, the latest version effective today), or the version whose id is in the context keyversion_id.Writing a version field on the employee changes that version; to change data from a date on, create a new version with
employee.create_version({'date_version': ..., ...}).A version is in contract when
contract_date_startis set; a contract is the set of versions sharing the same contract dates.Time computations (calendars, expected work time) follow the versions in contract.
Read Versions and contracts before writing any code on employees.
Access rights¶
hr defines two groups: Officer: Manage all employees (hr.group_hr_user) and
Administrator (hr.group_hr_manager, implying the former).
Model |
Internal users |
HR officers |
Multi-company rule |
|---|---|---|---|
|
none (they use |
all |
|
|
none |
all |
|
|
read |
read |
none |
|
read; update for the department’s manager and the employees above that manager |
all |
|
|
read |
all |
|
|
read |
all |
none |
|
read |
read (all for administrators) |
none |
|
all, for their own employee |
all |
none |
|
none |
all |
per company (departures) or per country of the allowed companies |
|
none |
none (all for administrators) |
per country of the allowed companies |
Within hr.employee, many fields are restricted further with groups (e.g. wage,
structure_type_id and employee_type_id are for administrators only). The rule to follow when
adding fields is explained in Public employees and access rights.