From edb9dad5f2afbe8fd9a90d44a8f9af307e3dc72a Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 22 Jan 2020 14:24:31 +0000 Subject: [PATCH] [FIX] base: Changing company_id of a partner with child_ids Steps to reproduce the bug: - Let's consider a company partner P with company_id = A - Let's consider an other partner C which is a child of P - Change the company_id of P to B Bug: The company_id of C was not changed even if the field company_id of C is in readonly as he has a parent. opw:2179632 closes odoo/odoo#44061 X-original-commit: f41f7dc0f4f2a1682c6f81aba6512306ecf86067 Signed-off-by: Simon Goffin (sig) --- odoo/addons/base/models/res_partner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py index 83d14da10e3..d110cb3598f 100644 --- a/odoo/addons/base/models/res_partner.py +++ b/odoo/addons/base/models/res_partner.py @@ -515,6 +515,8 @@ class Partner(models.Model): if len(companies) > 1 or company not in companies: raise UserError( ("The selected company is not compatible with the companies of the related user(s)")) + if partner.child_ids: + partner.child_ids.write({'company_id': company.id}) result = True # To write in SUPERUSER on field is_company and avoid access rights problems. if 'is_company' in vals and self.user_has_groups('base.group_partner_manager') and not self.env.su: