Browse Source

Fix init hook problem, more checks

pull/486/head
Giovanni Francesco Capalbo 7 years ago
parent
commit
6c78017402
  1. 15
      partner_multi_relation_parent/models/res_partner.py

15
partner_multi_relation_parent/models/res_partner.py

@ -32,12 +32,15 @@ class ResPartner(models.Model):
this.id, type_relation, old_parent_id this.id, type_relation, old_parent_id
) )
previous.unlink() previous.unlink()
# create new relations
par_rel_mod.create({
'left_partner_id': this.id,
'type_id': type_relation,
'right_partner_id': parent_id,
})
# create new relations only if all the needed partners are there
# for example if on create it failed this.id will be false or if it
# has no parent also would fail.
if this.id and parent_id:
par_rel_mod.create({
'left_partner_id': this.id,
'type_id': type_relation,
'right_partner_id': parent_id,
})
@api.model @api.model
def create(self, vals): def create(self, vals):

Loading…
Cancel
Save