diff --git a/partner_contact_in_several_companies/models/res_partner.py b/partner_contact_in_several_companies/models/res_partner.py index 8770cf0e8f45..8de77f167851 100644 --- a/partner_contact_in_several_companies/models/res_partner.py +++ b/partner_contact_in_several_companies/models/res_partner.py @@ -94,16 +94,14 @@ def unlink(self): return super(ResPartner, modified_self).unlink() @api.multi - def _commercial_partner_compute(self, name, args): + def _compute_commercial_partner(self): """ Returns the partner that is considered the commercial entity of this partner. The commercial entity holds the master data for all commercial fields (see :py:meth:`~_commercial_fields`) """ - result = super(ResPartner, self)._commercial_partner_compute(name, - args) + result = super(ResPartner, self)._compute_commercial_partner() for partner in self: if partner.contact_type == 'attached' and not partner.parent_id: - result[partner.id] = partner.contact_id.id - return result + partner.commercial_partner_id = partner.contact_id def _contact_fields(self): """ Returns the list of contact fields that are synced from the parent diff --git a/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py b/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py index e016c9744343..39b4ab887343 100644 --- a/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py +++ b/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py @@ -231,6 +231,13 @@ def test_07_contact_onchange(self): 'Bob Egnops', ) + new_contact.write({'parent_id': False}) + new_contact._compute_commercial_partner() + self.assertEqual( + new_contact.contact_id, + new_contact.commercial_partner_id, + ) + new_contact.write({'contact_type': 'standalone'}) new_contact._onchange_contact_type()