|
|
@ -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) |
|
|
|