Skip to content

Commit

Permalink
[FIX] compute_commercial_partner migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas JEUDY committed Nov 8, 2017
1 parent 3bb29e4 commit 1b8a746
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 3 additions & 5 deletions partner_contact_in_several_companies/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 1b8a746

Please sign in to comment.