From 3a219172a571cd798b1c96debc4ce935c457bfab Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Fri, 20 Oct 2023 14:21:29 +0200 Subject: [PATCH] [FIX] hr: not set partner of a bank account to `False` Steps to reproduce: ------------------- - install `account` module; - create an employee; - add a bank account; - add a related user and save; - remove the user and save; Issue: ------ A traceback occurs. Cause: ------ We synchronize the `partner_id` of the `bank_account` with the `work_contact_id`. If the latter is `False`, this triggers an error. Solution: --------- Do not trigger the logic that updates the `partner_id` of the `bank_account` if the value is `False`. This keeps the logic that the `partner_id` field in the `res.partner.bank` model is required. opw-3558983 closes odoo/odoo#139570 X-original-commit: c19574e26d8814a745152489eb16915f13b2a6c0 Signed-off-by: Sofie Gvaladze (sgv) Signed-off-by: Thomas Lefebvre (thle) --- addons/hr/models/hr_employee.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index a5a175357d3..5ab77b303a6 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -415,7 +415,8 @@ class HrEmployeePrivate(models.Model): if vals['work_contact_id'] != bank_account.partner_id.id: if bank_account.allow_out_payment: bank_account.sudo().allow_out_payment = False - bank_account.partner_id = vals['work_contact_id'] + if vals['work_contact_id']: + bank_account.partner_id = vals['work_contact_id'] self.message_unsubscribe(self.work_contact_id.ids) if vals['work_contact_id']: self._message_subscribe([vals['work_contact_id']])