Browse Source

[ADD] Financial risk approval on subscription

pull/19/head
Elouan Le Bars 5 years ago
parent
commit
7cf099fec4
  1. 6
      easy_my_coop/controllers/main.py
  2. 16
      easy_my_coop/models/company.py
  3. 19
      easy_my_coop/models/coop.py
  4. 5
      easy_my_coop/models/partner.py
  5. 3
      easy_my_coop/view/res_company_view.xml
  6. 1
      easy_my_coop/view/res_partner_view.xml
  7. 1
      easy_my_coop/view/subscription_request_view.xml
  8. 30
      easy_my_coop/view/subscription_template.xml

6
easy_my_coop/controllers/main.py

@ -172,6 +172,9 @@ class WebsiteSubscription(http.Controller):
'display_internal_rules': comp.display_internal_rules_approval,
'internal_rules_required': comp.internal_rules_approval_required,
'internal_rules_text': comp.internal_rules_approval_text,
'display_financial_risk': comp.display_financial_risk_approval,
'financial_risk_required': comp.financial_risk_approval_required,
'financial_risk_text': comp.financial_risk_approval_text,
})
return values
@ -353,6 +356,9 @@ class WebsiteSubscription(http.Controller):
if kwargs.get('internal_rules_approved', 'off') == 'on':
values['internal_rules_approved'] = True
if kwargs.get('financial_risk_approved', 'off') == 'on':
values['financial_risk_approved'] = True
lastname = kwargs.get("lastname").upper()
firstname = kwargs.get("firstname").title()

16
easy_my_coop/models/company.py

@ -66,6 +66,17 @@ class ResCompany(models.Model):
translate=True,
help="Text to display aside the checkbox to approve internal rules."
)
display_financial_risk_approval = fields.Boolean(
help="Choose to display a financial risk checkbox on the"
" cooperator website form."
)
financial_risk_approval_required = fields.Boolean(
string="Is financial risk approval required?"
)
financial_risk_approval_text = fields.Html(
translate=True,
help="Text to display aside the checkbox to approve financial risk."
)
@api.onchange('data_policy_approval_required')
def onchange_data_policy_approval_required(self):
@ -76,3 +87,8 @@ class ResCompany(models.Model):
def onchange_internal_rules_approval_required(self):
if self.internal_rules_approval_required:
self.display_internal_rules_approval = True
@api.onchange('financial_risk_approval_required')
def onchange_financial_risk_approval_required(self):
if self.financial_risk_approval_required:
self.display_financial_risk_rules_approval = True

19
easy_my_coop/models/coop.py

@ -35,6 +35,8 @@ class subscription_request(models.Model):
required_fields.append('data_policy_approved')
if company.internal_rules_approval_required:
required_fields.append('internal_rules_approved')
if company.financial_risk_approval_required:
required_fields.append('financial_risk_approved')
return required_fields
@api.model
@ -309,7 +311,11 @@ class subscription_request(models.Model):
default=False,
)
internal_rules_approved = fields.Boolean(
string='Approved Internal Rules',
string='Internal Rules Approved ',
default=False,
)
financial_risk_approved = fields.Boolean(
string='Financial Risk Approved',
default=False,
)
_order = "id desc"
@ -429,7 +435,8 @@ class subscription_request(models.Model):
'country_id': self.country_id.id,
'lang': self.lang,
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved
'internal_rules_approved': self.internal_rules_approved,
'financial_risk_approved': self.financial_risk_approved
}
return partner_vals
@ -445,7 +452,9 @@ class subscription_request(models.Model):
'birthdate_date': self.birthdate,
'customer': self.share_product_id.customer,
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved}
'internal_rules_approved': self.internal_rules_approved,
'financial_risk_approved': self.financial_risk_approved
}
return partner_vals
def create_coop_partner(self):
@ -518,7 +527,9 @@ class subscription_request(models.Model):
'function': self.contact_person_function,
'type': 'representative',
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved}
'internal_rules_approved': self.internal_rules_approved,
'financial_risk_approved': self.financial_risk_approved
}
contact = partner_obj.create(contact_vals)
else:
if len(contact) > 1:

5
easy_my_coop/models/partner.py

@ -144,8 +144,9 @@ class ResPartner(models.Model):
string="Subscription request")
legal_form = fields.Selection([('', '')],
string="Legal form")
data_policy_approved = fields.Boolean(string="Approved Data Policy")
internal_rules_approved = fields.Boolean(string="Approved Internal Rules")
data_policy_approved = fields.Boolean(string="Data Policy Approved ")
internal_rules_approved = fields.Boolean(string="Internal Rules Approved ")
financial_risk_approved = fields.Boolean(string="Financial Risk Approved ")
@api.multi
@api.depends('subscription_request_ids.state')

3
easy_my_coop/view/res_company_view.xml

@ -27,6 +27,9 @@
<field name="display_internal_rules_approval"/>
<field name="internal_rules_approval_required"/>
<field name="internal_rules_approval_text"/>
<field name="display_financial_risk_approval"/>
<field name="financial_risk_approval_required"/>
<field name="financial_risk_approval_text"/>
</group>
</xpath>
</field>

1
easy_my_coop/view/res_partner_view.xml

@ -33,6 +33,7 @@
<group name="approvals">
<field name="data_policy_approved" />
<field name="internal_rules_approved" />
<field name="financial_risk_approved" />
</group>
</xpath>

1
easy_my_coop/view/subscription_request_view.xml

@ -76,6 +76,7 @@
<field name="skip_control_ng"/>
<field name="data_policy_approved"/>
<field name="internal_rules_approved"/>
<field name="financial_risk_approved"/>
</group>
</group>
<notebook>

30
easy_my_coop/view/subscription_template.xml

@ -293,6 +293,21 @@
</div>
</div>
<div id="financial_risk_approved" t-if="display_financial_risk" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="financial_risk_approved">Financial Risk</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="financial_risk_approved"
t-att-required="financial_risk_required"
t-att-checked="financial_risk_approved"/>
<t t-raw="financial_risk_text"/>
</label>
</div>
</div>
</div>
<table style="margin-left:195px">
<tr>
<td width="80%">
@ -624,6 +639,21 @@
</div>
</div>
<div id="financial_risk_approved" t-if="display_financial_risk" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="financial_risk_approved">Financial Risk</label>
<div class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="financial_risk_approved"
t-att-required="financial_risk_required"
t-att-checked="financial_risk_approved"/>
<t t-raw="financial_risk_text"/>
</label>
</div>
</div>
</div>
<div t-attf-class="form-group" >
<div class="col-md-7 col-sm-8">
<table style="margin-left:195px">

Loading…
Cancel
Save