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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
18 additions and
5 deletions
-
easy_my_coop/models/coop.py
-
easy_my_coop/models/partner.py
-
easy_my_coop/view/res_partner_view.xml
-
easy_my_coop/view/subscription_request_view.xml
|
|
@ -322,6 +322,15 @@ class subscription_request(models.Model): |
|
|
|
) |
|
|
|
_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): |
|
|
|
self.firstname = partner.firstname |
|
|
|
self.name = partner.name |
|
|
@ -482,8 +491,6 @@ class subscription_request(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 |
|
|
@ -504,6 +511,11 @@ class subscription_request(models.Model): |
|
|
|
else: |
|
|
|
partner = partner[0] |
|
|
|
|
|
|
|
partner.write({ |
|
|
|
"cooperator": True, |
|
|
|
"customer": self.share_product_id.customer |
|
|
|
}) |
|
|
|
|
|
|
|
if self.is_company and not partner.has_representative(): |
|
|
|
contact = False |
|
|
|
if self.email: |
|
|
|
|
|
@ -102,7 +102,7 @@ class ResPartner(models.Model): |
|
|
|
partner.number_of_share = number_of_share |
|
|
|
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" |
|
|
|
" cooperator(effective or not).") |
|
|
|
member = fields.Boolean(string='Effective cooperator', |
|
|
|
|
|
@ -18,6 +18,7 @@ |
|
|
|
<xpath expr="/form/sheet/group" position='before'> |
|
|
|
<group> |
|
|
|
<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="legal_form" attrs="{'invisible':[('is_company','=',False)]}"/> |
|
|
|
<field name="company_register_number" readonly="True" attrs="{'invisible':[('is_company','=',False)]}"/> |
|
|
|
|
|
@ -42,8 +42,8 @@ |
|
|
|
<field name="already_cooperator"/> |
|
|
|
<field name="is_company" groups="easy_my_coop.group_energiris_super_manager"/> |
|
|
|
<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_register_number" attrs="{'invisible':[('is_company','=',False)]}"/> |
|
|
|
<field name="name"/> |
|
|
|