From aeb63498deaca76b070b1a5d435c1a3a3c0a72ac Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Thu, 24 Aug 2023 08:31:07 +0000 Subject: [PATCH] [FIX] hr_employee: ensure desynchronization with user Steps to reproduce: ------------------- - create a new employee; - link it to an existing user; - save (trigger a validation error); - remove the related user; - save; - change the email address of this new employee; Issue: ------ The email address of the employee linked to the user that we tried to link is updated. Cause: ------ We don't sync the employee with the user if the user is `False`, i.e. we don't update the employee's `work_contact_id` if the `user_id` is `False`. Solution: --------- Update the `work_contact_id` in any case. opw-3475002 closes odoo/odoo#133191 X-original-commit: c2f2dc3e49ee7cd96d4da05f2236441e65090753 Signed-off-by: Sofie Gvaladze (sgv) Signed-off-by: Thomas Lefebvre (thle) --- addons/hr/models/hr_employee.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index 812ea2b55b5..50a96da25b2 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -332,10 +332,9 @@ class HrEmployeePrivate(models.Model): @api.onchange('user_id') def _onchange_user(self): - if self.user_id: - self.update(self._sync_user(self.user_id, (bool(self.image_1920)))) - if not self.name: - self.name = self.user_id.name + self.update(self._sync_user(self.user_id, (bool(self.image_1920)))) + if not self.name: + self.name = self.user_id.name @api.onchange('resource_calendar_id') def _onchange_timezone(self):