Browse Source

[FIX] partner cooperator flag

pull/33/head
robin.keunen 5 years ago
parent
commit
dbe9aa15ef
  1. 9
      easy_my_coop/models/coop.py

9
easy_my_coop/models/coop.py

@ -450,7 +450,7 @@ class SubscriptionRequest(models.Model):
partner_vals = {'name': self.company_name, partner_vals = {'name': self.company_name,
'last_name': self.company_name, 'last_name': self.company_name,
'is_company': self.is_company, 'is_company': self.is_company,
'company_register_number': self.company_register_number, #noqa
'company_register_number': self.company_register_number, # noqa
'customer': False, 'cooperator': True, 'customer': False, 'cooperator': True,
'street': self.address, 'zip': self.zip_code, 'street': self.address, 'zip': self.zip_code,
'city': self.city, 'email': self.company_email, 'city': self.city, 'email': self.company_email,
@ -535,21 +535,20 @@ class SubscriptionRequest(models.Model):
raise UserError(_('The checkbox already cooperator is' raise UserError(_('The checkbox already cooperator is'
' checked please select a cooperator.')) ' checked please select a cooperator.'))
elif self.is_company and self.company_register_number: elif self.is_company and self.company_register_number:
domain = [('company_register_number', '=', self.company_register_number)] #noqa
domain = [('company_register_number', '=', self.company_register_number)] # noqa
elif not self.is_company and self.email: elif not self.is_company and self.email:
domain = [('email', '=', self.email)] domain = [('email', '=', self.email)]
if domain: if domain:
partner = partner_obj.search(domain) partner = partner_obj.search(domain)
if not partner.cooperator:
partner.cooperator = True
if not partner: if not partner:
partner = self.create_coop_partner() partner = self.create_coop_partner()
else: else:
partner = partner[0] partner = partner[0]
partner.cooperator = True
if self.is_company and not partner.has_representative(): if self.is_company and not partner.has_representative():
contact = False contact = False
if self.email: if self.email:

Loading…
Cancel
Save