Browse Source

Merge pull request #39 from coopiteasy/12.0-easy-my-coop-fixes

12.0 easy my coop fixes
pull/35/head
Houssine BAKKALI 5 years ago
committed by GitHub
parent
commit
166e1ee698
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      easy_my_coop/models/coop.py
  2. 1
      easy_my_coop/wizard/create_subscription_from_partner.py
  3. 2
      easy_my_coop/wizard/create_subscription_from_partner.xml
  4. 7
      easy_my_coop/wizard/update_partner_info.py
  5. 3
      easy_my_coop/wizard/update_partner_info.xml

14
easy_my_coop/models/coop.py

@ -65,22 +65,19 @@ class SubscriptionRequest(models.Model):
cooperator = partner_obj.get_cooperator_from_email(
vals.get('email'))
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
cooperator = cooperator[0]
vals['type'] = 'subscription'
vals = self.is_member(vals, cooperator)
vals['partner_id'] = cooperator.id
if not cooperator.cooperator:
cooperator.write({'cooperator': True})
else:
cooperator_id = vals.get('partner_id')
cooperator = partner_obj.browse(cooperator_id)
vals = self.is_member(vals, cooperator)
if not cooperator.cooperator:
cooperator.write({'cooperator': True})
subscr_request = super(SubscriptionRequest, self).create(vals)
confirmation_mail_template = self.env.ref(mail_template, False)
@ -530,8 +527,6 @@ class SubscriptionRequest(models.Model):
if self.ordered_parts <= 0:
raise UserError(_('Number of share must be greater than 0.'))
if self.partner_id:
if not self.partner_id.cooperator:
self.partner_id.cooperator = True
partner = self.partner_id
else:
partner = None
@ -547,6 +542,9 @@ class SubscriptionRequest(models.Model):
if domain:
partner = partner_obj.search(domain)
if not partner.cooperator:
partner.cooperator = True
if not partner:
partner = self.create_coop_partner()
else:

1
easy_my_coop/wizard/create_subscription_from_partner.py

@ -98,7 +98,6 @@ class PartnerCreateSubscription(models.TransientModel):
string="Cooperator",
default=_get_partner)
register_number = fields.Char(string="Register Company Number",
required=True,
default=_get_register_number)
email = fields.Char(string="Email",
required=True,

2
easy_my_coop/wizard/create_subscription_from_partner.xml

@ -15,7 +15,7 @@
<field name="representative_name" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="representative_email" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="email"/>
<field name="register_number"/>
<field name="register_number" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="bank_account"/>
<field name="share_product" widget="selection"/>
<field name="share_qty"/>

7
easy_my_coop/wizard/update_partner_info.py

@ -16,8 +16,13 @@ class PartnerUpdateInfo(models.TransientModel):
if partner.is_company:
return partner.company_register_number
@api.model
def _get_is_company(self):
return self._get_partner().is_company
is_company = fields.Boolean(string="Is company",
default=_get_is_company)
register_number = fields.Char(string="Register Company Number",
required=True,
default=_get_register_number)
cooperator = fields.Many2one('res.partner',
string="Cooperator",

3
easy_my_coop/wizard/update_partner_info.xml

@ -10,12 +10,13 @@
Update Cooperator Info.
</p>
<group>
<field name="is_company" invisible="True"/>
<field name="all"/>
<field name="birthdate"/>
<field name="legal_form"/>
<field name="representative_function"/>
<field name="cooperator" readonly="True"/>
<field name="register_number" attrs="{'required':[('all', '=', False)]}"/>
<field name="register_number" attrs="{'required':['|', ('is_company', '=', True), ('all', '=', False)], 'invisible':[('is_company', '=', False)]}"/>
</group>
<footer>
<button name="update" string="Update Info" type="object" class="btn-primary"/>

Loading…
Cancel
Save