Browse Source

[FIX] model that same pattern for _fields_sync

- add test ensure_once()
pull/347/head
Nicolas JEUDY 8 years ago
parent
commit
a042979ca1
  1. 12
      partner_contact_in_several_companies/models/res_partner.py

12
partner_contact_in_several_companies/models/res_partner.py

@ -138,18 +138,18 @@ class ResPartner(models.Model):
after create/update, just as if those were all modeled as
fields.related to the parent
"""
self.ensure_one()
super(ResPartner, self)._fields_sync(update_values)
for record in self:
contact_fields = record._contact_fields()
contact_fields = self._contact_fields()
# 1. From UPSTREAM: sync from parent contact
if update_values.get('contact_id'):
record._contact_sync_from_parent()
self._contact_sync_from_parent()
# 2. To DOWNSTREAM: sync contact fields to parent or related
elif any(field in contact_fields for field in update_values):
update_ids = record.other_contact_ids.filtered(
update_ids = self.other_contact_ids.filtered(
lambda p: not p.is_company)
if record.contact_id:
update_ids |= record.contact_id
if self.contact_id:
update_ids |= self.contact_id
update_ids.update_contact(update_values)
@api.onchange('contact_id')

Loading…
Cancel
Save