|
@ -65,22 +65,19 @@ class SubscriptionRequest(models.Model): |
|
|
cooperator = partner_obj.get_cooperator_from_email( |
|
|
cooperator = partner_obj.get_cooperator_from_email( |
|
|
vals.get('email')) |
|
|
vals.get('email')) |
|
|
if cooperator: |
|
|
if cooperator: |
|
|
# TODO remove the following line of code once it has |
|
|
|
|
|
|
|
|
# TODO remove the following line once it has |
|
|
# been found a way to avoid double encoding |
|
|
# been found a way to avoid double encoding |
|
|
cooperator = cooperator[0] |
|
|
cooperator = cooperator[0] |
|
|
vals['type'] = 'subscription' |
|
|
vals['type'] = 'subscription' |
|
|
|
|
|
|
|
|
vals = self.is_member(vals, cooperator) |
|
|
vals = self.is_member(vals, cooperator) |
|
|
|
|
|
|
|
|
vals['partner_id'] = cooperator.id |
|
|
vals['partner_id'] = cooperator.id |
|
|
|
|
|
|
|
|
if not cooperator.cooperator: |
|
|
|
|
|
cooperator.write({'cooperator': True}) |
|
|
|
|
|
else: |
|
|
else: |
|
|
cooperator_id = vals.get('partner_id') |
|
|
cooperator_id = vals.get('partner_id') |
|
|
cooperator = partner_obj.browse(cooperator_id) |
|
|
cooperator = partner_obj.browse(cooperator_id) |
|
|
vals = self.is_member(vals, cooperator) |
|
|
vals = self.is_member(vals, cooperator) |
|
|
|
|
|
|
|
|
|
|
|
if not cooperator.cooperator: |
|
|
|
|
|
cooperator.write({'cooperator': True}) |
|
|
subscr_request = super(SubscriptionRequest, self).create(vals) |
|
|
subscr_request = super(SubscriptionRequest, self).create(vals) |
|
|
|
|
|
|
|
|
confirmation_mail_template = self.env.ref(mail_template, False) |
|
|
confirmation_mail_template = self.env.ref(mail_template, False) |
|
@ -530,8 +527,6 @@ class SubscriptionRequest(models.Model): |
|
|
if self.ordered_parts <= 0: |
|
|
if self.ordered_parts <= 0: |
|
|
raise UserError(_('Number of share must be greater than 0.')) |
|
|
raise UserError(_('Number of share must be greater than 0.')) |
|
|
if self.partner_id: |
|
|
if self.partner_id: |
|
|
if not self.partner_id.cooperator: |
|
|
|
|
|
self.partner_id.cooperator = True |
|
|
|
|
|
partner = self.partner_id |
|
|
partner = self.partner_id |
|
|
else: |
|
|
else: |
|
|
partner = None |
|
|
partner = None |
|
@ -547,6 +542,9 @@ class SubscriptionRequest(models.Model): |
|
|
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: |
|
|