Browse Source

[FIX] fixes cooperator validation with same email for company and representative

14.0-MIG-INITIAL
default 4 years ago
parent
commit
c76a903ba4
  1. 11
      easy_my_coop/models/coop.py

11
easy_my_coop/models/coop.py

@ -699,10 +699,17 @@ class SubscriptionRequest(models.Model):
if self.is_company and not partner.has_representative():
contact = False
if self.email:
domain = [("email", "=", self.email)]
domain = [("email", "=", self.email),
('company_type', '=', 'person')]
contact = partner_obj.search(domain)
if contact:
if len(contact) < 2:
contact.type = "representative"
else:
raise UserError(
_(
"You have duplicate contact with email %s" % self.email
)
)
if not contact:
contact_vals = self.get_representative_vals()
partner_obj.create(contact_vals)

Loading…
Cancel
Save