From a8b5a53e6002247051e9e50bd575b66fd1e65eb3 Mon Sep 17 00:00:00 2001 From: Noe Antoine Date: Tue, 4 Jan 2022 16:09:53 +0000 Subject: [PATCH] [REF][ADD] hr: split appointment module according to hr dependancy When setting users on the appointment type as staff, we want to consider their resource_calendar_id (work schedules) only if they correspond to the current company and are linked to employees, not the ones linked to the users directly. In order to display those work hours correctly, we use a new related field on the employee_id in res_users model as it will return the employee of the user in the current company, if any. Therefore, we add the new field employee_resource_calendar_id directly in hr module (in res.users model) to reduce diff and centralize the fields as close as possible to the employee_id definition. --- Links --- Task-2499566 closes odoo/odoo#82234 Related: odoo/enterprise#17934 Related: odoo/upgrade#2578 Signed-off-by: Thibault Delavallee (tde) --- addons/hr/models/res_users.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/hr/models/res_users.py b/addons/hr/models/res_users.py index 6853f059748..2dc47730b9d 100644 --- a/addons/hr/models/res_users.py +++ b/addons/hr/models/res_users.py @@ -17,6 +17,7 @@ HR_READABLE_FIELDS = [ 'last_activity_time', 'can_edit', 'is_system', + 'employee_resource_calendar_id', ] HR_WRITABLE_FIELDS = [ @@ -136,6 +137,7 @@ class User(models.Model): last_activity = fields.Date(related='employee_id.last_activity') last_activity_time = fields.Char(related='employee_id.last_activity_time') employee_type = fields.Selection(related='employee_id.employee_type', readonly=False, related_sudo=False) + employee_resource_calendar_id = fields.Many2one(related='employee_id.resource_calendar_id', string="Employee's Working Hours", readonly=True) can_edit = fields.Boolean(compute='_compute_can_edit') is_system = fields.Boolean(compute="_compute_is_system")