Browse Source

Merge pull request #2

[ADD] emc: Require data policy approval
pull/4/head
Rémy Taymans 6 years ago
committed by GitHub
parent
commit
03776220e3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      easy_my_coop/__openerp__.py
  2. 6
      easy_my_coop/controllers/main.py
  3. 26
      easy_my_coop/models/coop.py
  4. 2
      easy_my_coop/models/partner.py
  5. 4
      easy_my_coop/view/res_partner_view.xml
  6. 2
      easy_my_coop/view/subscription_request_view.xml
  7. 118
      easy_my_coop/view/subscription_template.xml

2
easy_my_coop/__openerp__.py

@ -20,7 +20,7 @@
############################################################################## ##############################################################################
{ {
"name": "Easy My Coop", "name": "Easy My Coop",
"version": "1.1",
"version": "9.0.1.2.0",
"depends": ["base", "depends": ["base",
"sale", "sale",
"purchase", "purchase",

6
easy_my_coop/controllers/main.py

@ -340,6 +340,12 @@ class WebsiteSubscription(http.Controller):
values["already_cooperator"] = already_coop values["already_cooperator"] = already_coop
values["is_company"] = is_company values["is_company"] = is_company
if kwargs.get('data_policy_approved', 'off') == 'on':
values['data_policy_approved'] = True
if kwargs.get('internal_rules_approved', 'off') == 'on':
values['internal_rules_approved'] = True
lastname = kwargs.get("lastname").upper() lastname = kwargs.get("lastname").upper()
firstname = kwargs.get("firstname").title() firstname = kwargs.get("firstname").title()

26
easy_my_coop/models/coop.py

@ -16,6 +16,8 @@ _REQUIRED = ['email',
'city', 'city',
'iban', 'iban',
'no_registre', 'no_registre',
'data_policy_approved',
'internal_rules_approved',
'gender'] # Could be improved including required from model 'gender'] # Could be improved including required from model
@ -329,6 +331,16 @@ class subscription_request(models.Model):
default="website", default="website",
readonly=True, readonly=True,
states={'draft': [('readonly', False)]}) states={'draft': [('readonly', False)]})
data_policy_approved = fields.Boolean(
string='Data Policy Approved',
default=False,
# required=True,
)
internal_rules_approved = fields.Boolean(
string='Approved Internal Rules',
default=False,
# required=True,
)
_order = "id desc" _order = "id desc"
def get_person_info(self, partner): def get_person_info(self, partner):
@ -437,14 +449,16 @@ class subscription_request(models.Model):
'last_name': self.company_name, 'last_name': self.company_name,
'is_company': self.is_company, 'is_company': self.is_company,
'company_register_number': self.company_register_number, #noqa 'company_register_number': self.company_register_number, #noqa
'customer': False, 'cooperator': True,
'cooperator': True,
'street': self.address, 'zip': self.zip_code, 'street': self.address, 'zip': self.zip_code,
'city': self.city, 'email': self.company_email, 'city': self.city, 'email': self.company_email,
'out_inv_comm_type': 'bba', 'out_inv_comm_type': 'bba',
'customer': self.share_product_id.customer, 'customer': self.share_product_id.customer,
'out_inv_comm_algorithm': 'random', 'out_inv_comm_algorithm': 'random',
'country_id': self.country_id.id, 'country_id': self.country_id.id,
'lang': self.lang}
'lang': self.lang,
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved}
return partner_vals return partner_vals
def get_partner_vals(self): def get_partner_vals(self):
@ -458,7 +472,9 @@ class subscription_request(models.Model):
'out_inv_comm_algorithm': 'random', 'out_inv_comm_algorithm': 'random',
'country_id': self.country_id.id, 'lang': self.lang, 'country_id': self.country_id.id, 'lang': self.lang,
'birthdate_date': self.birthdate, 'birthdate_date': self.birthdate,
'customer': self.share_product_id.customer}
'customer': self.share_product_id.customer,
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved}
return partner_vals return partner_vals
def create_coop_partner(self): def create_coop_partner(self):
@ -530,7 +546,9 @@ class subscription_request(models.Model):
'parent_id': partner.id, 'parent_id': partner.id,
'representative': True, 'representative': True,
'function': self.contact_person_function, 'function': self.contact_person_function,
'type': 'representative'}
'type': 'representative',
'data_policy_approved': self.data_policy_approved,
'internal_rules_approved': self.internal_rules_approved}
contact = partner_obj.create(contact_vals) contact = partner_obj.create(contact_vals)
else: else:
if len(contact) > 1: if len(contact) > 1:

2
easy_my_coop/models/partner.py

@ -139,6 +139,8 @@ class ResPartner(models.Model):
subscription_request_ids = fields.One2many('subscription.request', subscription_request_ids = fields.One2many('subscription.request',
'partner_id', 'partner_id',
string="Subscription request") string="Subscription request")
data_policy_approved = fields.Boolean(string="Approved Data Policy")
internal_rules_approved = fields.Boolean(string="Approved Internal Rules")
@api.multi @api.multi
@api.depends('subscription_request_ids.state') @api.depends('subscription_request_ids.state')

4
easy_my_coop/view/res_partner_view.xml

@ -30,6 +30,10 @@
<group> <group>
<field name="gender" attrs="{'invisible':[('is_company','=',True)]}"/> <field name="gender" attrs="{'invisible':[('is_company','=',True)]}"/>
</group> </group>
<group name="approvals">
<field name="data_policy_approved" />
<field name="internal_rules_approved" />
</group>
</xpath> </xpath>
<xpath expr="//page[@name='sales_purchases']" position='after'> <xpath expr="//page[@name='sales_purchases']" position='after'>

2
easy_my_coop/view/subscription_request_view.xml

@ -79,6 +79,8 @@
<field name="lang"/> <field name="lang"/>
<field name="validated"/> <field name="validated"/>
<field name="skip_control_ng"/> <field name="skip_control_ng"/>
<field name="data_policy_approved"/>
<field name="internal_rules_approved"/>
</group> </group>
</group> </group>
<notebook> <notebook>

118
easy_my_coop/view/subscription_template.xml

@ -70,12 +70,18 @@
</label> </label>
</div> </div>
<div t-attf-class="form-group">
<label>
<input type="checkbox" t-att-value="already_cooperator" name="already_cooperator" />
Already cooperator?
</label>
</div>
<div t-attf-class="form-group">
<div class="row">
<label class="col-md-3 col-sm-4 control-label" for="already_cooperator">Already cooperator?</label>
<div class="col-md-2 col-sm-2">
<input type="checkbox"
class="form-control"
name="already_cooperator"
t-att-value="already_cooperator"
/>
</div>
</div>
</div>
<div name="email_from_container" t-attf-class="form-group #{error and 'email_from' in error and 'has-error' or ''}"> <div name="email_from_container" t-attf-class="form-group #{error and 'email_from' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label" for="email">Email</label> <label class="col-md-3 col-sm-4 control-label" for="email">Email</label>
@ -240,6 +246,35 @@
<br/> <br/>
<div t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="internal_rules_approved">Internal Rules</label>
<div class="col-md-1 col-sm-2">
<input type="checkbox"
class="form-control"
name="internal_rules_approved"
required="True"
t-attf-value="#{internal_rules_approved or ''}"/>
</div>
<div class="col-md-6 col-sm-6">
<t t-call="easy_my_coop.internal_rules_approved_text"/>
</div>
</div>
<div t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="data_policy_approved">Privacy Policy</label>
<div class="col-md-1 col-sm-2">
<input type="checkbox"
class="form-control"
name="data_policy_approved"
required="True"
t-attf-value="#{data_policy_approved or ''}"/>
</div>
<div class="col-md-6 col-sm-6">
<t t-call="easy_my_coop.data_policy_approved_text"/>
</div>
</div>
<table style="margin-left:195px"> <table style="margin-left:195px">
<tr> <tr>
<td width="80%"> <td width="80%">
@ -502,20 +537,52 @@
<br/> <br/>
<table style="margin-left:195px">
<tr>
<td width="80%">
<div class="g-recaptcha" t-att-data-sitekey="website.recaptcha_site_key" data-theme="green"/><br/>
</td>
<td>
<div class="form-group">
<div class="col-md-offset-3 col-sm-offset-4 col-sm-8 col-md-7">
<button class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</td>
</tr>
</table>
<div t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="internal_rules_approved">Internal Rules</label>
<div class="col-md-1 col-sm-2">
<input type="checkbox"
class="form-control"
name="internal_rules_approved"
required="True"
t-attf-value="#{internal_rules_approved or ''}"/>
</div>
<div class="col-md-6 col-sm-6">
<t t-call="easy_my_coop.internal_rules_approved_text"/>
</div>
</div>
<div t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="data_policy_approved">Privacy Policy</label>
<div class="col-md-1 col-sm-2">
<input type="checkbox"
class="form-control"
name="data_policy_approved"
required="True"
t-attf-value="#{data_policy_approved or ''}"/>
</div>
<div class="col-md-6 col-sm-6">
<t t-call="easy_my_coop.data_policy_approved_text"/>
</div>
</div>
<div t-attf-class="form-group" >
<div class="col-md-7 col-sm-8">
<table style="margin-left:195px">
<tr>
<td width="80%">
<div class="g-recaptcha" t-att-data-sitekey="website.recaptcha_site_key" data-theme="green"/><br/>
</td>
<td>
<div class="form-group">
<div class="col-md-offset-3 col-sm-offset-4 col-sm-8 col-md-7">
<button class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
<br/> <br/>
</form> </form>
@ -551,4 +618,15 @@
</xpath> </xpath>
</template> </template>
</data> </data>
<data noupdate="1">
<template id="data_policy_approved_text"
name="Internal Rules Approved Text">
I accept the Data Policy.
</template>
<template id="internal_rules_approved_text"
name="Internal Rules Approved Text">
I accept the Internal Rules.
</template>
</data>
</openerp> </openerp>
Loading…
Cancel
Save