Browse Source

Merge pull request #89 from coopiteasy/9.0-fix-when-parner-existing

9.0 fix when partner existing
pull/95/head
Houssine BAKKALI 5 years ago
committed by GitHub
parent
commit
7d62c32a6a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      easy_my_coop/models/coop.py
  2. 2
      easy_my_coop/models/partner.py
  3. 1
      easy_my_coop/view/res_partner_view.xml
  4. 4
      easy_my_coop/view/subscription_request_view.xml

16
easy_my_coop/models/coop.py

@ -322,6 +322,15 @@ class subscription_request(models.Model):
) )
_order = "id desc" _order = "id desc"
@api.multi
@api.constrains("company_email", "email")
def _check_company_email(self):
"""Ensure that company_email and email are different"""
for sub_req in self:
if sub_req.company_email == sub_req.email:
raise UserError(_("Company email and email can't "
"be the same."))
def get_person_info(self, partner): def get_person_info(self, partner):
self.firstname = partner.firstname self.firstname = partner.firstname
self.name = partner.name self.name = partner.name
@ -482,8 +491,6 @@ class subscription_request(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
@ -504,6 +511,11 @@ class subscription_request(models.Model):
else: else:
partner = partner[0] partner = partner[0]
partner.write({
"cooperator": True,
"customer": self.share_product_id.customer
})
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:

2
easy_my_coop/models/partner.py

@ -102,7 +102,7 @@ class ResPartner(models.Model):
partner.number_of_share = number_of_share partner.number_of_share = number_of_share
partner.total_value = total_value partner.total_value = total_value
cooperator = fields.Boolean(string='Cooperator',
cooperator = fields.Boolean(string='Easy My Coop',
help="Check this box if this contact is a" help="Check this box if this contact is a"
" cooperator(effective or not).") " cooperator(effective or not).")
member = fields.Boolean(string='Effective cooperator', member = fields.Boolean(string='Effective cooperator',

1
easy_my_coop/view/res_partner_view.xml

@ -18,6 +18,7 @@
<xpath expr="/form/sheet/group" position='before'> <xpath expr="/form/sheet/group" position='before'>
<group> <group>
<field name="representative" attrs="{'invisible':['|',('parent_id','=',False),('is_company','=',True)]}"/> <field name="representative" attrs="{'invisible':['|',('parent_id','=',False),('is_company','=',True)]}"/>
<field name="cooperator" groups="base.group_system"/>
<field name="cooperator_register_number" readonly="True" attrs="{'invisible':[('member','=',False)]}"/> <field name="cooperator_register_number" readonly="True" attrs="{'invisible':[('member','=',False)]}"/>
<field name="legal_form" attrs="{'invisible':[('is_company','=',False)]}"/> <field name="legal_form" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_register_number" readonly="True" attrs="{'invisible':[('is_company','=',False)]}"/> <field name="company_register_number" readonly="True" attrs="{'invisible':[('is_company','=',False)]}"/>

4
easy_my_coop/view/subscription_request_view.xml

@ -42,8 +42,8 @@
<field name="already_cooperator"/> <field name="already_cooperator"/>
<field name="is_company" groups="easy_my_coop.group_energiris_super_manager"/> <field name="is_company" groups="easy_my_coop.group_energiris_super_manager"/>
<field name="is_operation" invisible="True"/> <field name="is_operation" invisible="True"/>
<field name="company_name" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_email" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_name" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="company_email" attrs="{'invisible':[('is_company','=',False)],'required':[('is_company','=',True)]}"/>
<field name="company_type" attrs="{'invisible':[('is_company','=',False)]}"/> <field name="company_type" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="company_register_number" attrs="{'invisible':[('is_company','=',False)]}"/> <field name="company_register_number" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="name"/> <field name="name"/>

Loading…
Cancel
Save