Browse Source

Merge pull request #4

[IMP] emc: Data policy and internal rules approval
pull/5/head
Rémy Taymans 6 years ago
committed by GitHub
parent
commit
e494befa02
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      easy_my_coop/__openerp__.py
  2. 20
      easy_my_coop/controllers/main.py
  3. 34
      easy_my_coop/models/company.py
  4. 12
      easy_my_coop/models/coop.py
  5. 6
      easy_my_coop/view/res_company_view.xml
  6. 95
      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": "9.0.1.2.0",
"version": "9.0.1.3.0",
"depends": ["base", "depends": ["base",
"sale", "sale",
"purchase", "purchase",

20
easy_my_coop/controllers/main.py

@ -46,6 +46,16 @@ class WebsiteSubscription(http.Controller):
values[field] = kwargs.pop(field) values[field] = kwargs.pop(field)
values.update(kwargs=kwargs.items()) values.update(kwargs=kwargs.items())
# Configuration
cmp = request.env['res.company']._company_default_get()
values.update({
'display_data_policy': cmp.display_data_policy_approval,
'data_policy_required': cmp.data_policy_approval_required,
'data_policy_text': cmp.data_policy_approval_text,
'display_internal_rules': cmp.display_internal_rules_approval,
'internal_rules_required': cmp.internal_rules_approval_required,
'internal_rules_text': cmp.internal_rules_approval_text,
})
return request.website.render("easy_my_coop.becomecooperator", values) return request.website.render("easy_my_coop.becomecooperator", values)
@http.route(['/page/become_company_cooperator', @http.route(['/page/become_company_cooperator',
@ -63,6 +73,16 @@ class WebsiteSubscription(http.Controller):
if kwargs.get(field): if kwargs.get(field):
values[field] = kwargs.pop(field) values[field] = kwargs.pop(field)
values.update(kwargs=kwargs.items()) values.update(kwargs=kwargs.items())
# Configuration
cmp = request.env['res.company']._company_default_get()
values.update({
'display_data_policy': cmp.display_data_policy_approval,
'data_policy_required': cmp.data_policy_approval_required,
'data_policy_text': cmp.data_policy_approval_text,
'display_internal_rules': cmp.display_internal_rules_approval,
'internal_rules_required': cmp.internal_rules_approval_required,
'internal_rules_text': cmp.internal_rules_approval_text,
})
return request.website.render("easy_my_coop.becomecompanycooperator", values) return request.website.render("easy_my_coop.becomecompanycooperator", values)
def preRenderThanks(self, values, kwargs): def preRenderThanks(self, values, kwargs):

34
easy_my_coop/models/company.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from openerp import fields, models
from openerp import api, fields, models
class ResCompany(models.Model): class ResCompany(models.Model):
@ -44,3 +44,35 @@ class ResCompany(models.Model):
bottom_logo2 = fields.Binary(string="Bottom logo 2") bottom_logo2 = fields.Binary(string="Bottom logo 2")
logo_url = fields.Char(string="logo url", logo_url = fields.Char(string="logo url",
compute="_get_base_logo") compute="_get_base_logo")
display_data_policy_approval = fields.Boolean(
help="Choose to display a data policy checkbox on the cooperator"
" website form."
)
data_policy_approval_required = fields.Boolean(
string="Is data policy approval required?"
)
data_policy_approval_text = fields.Html(
translate=True,
help="Text to display aside the checkbox to approve data policy."
)
display_internal_rules_approval = fields.Boolean(
help="Choose to display an internal rules checkbox on the"
" cooperator website form."
)
internal_rules_approval_required = fields.Boolean(
string="Is internal rules approval required?"
)
internal_rules_approval_text = fields.Html(
translate=True,
help="Text to display aside the checkbox to approve internal rules."
)
@api.onchange('data_policy_approval_required')
def onchange_data_policy_approval_required(self):
if self.data_policy_approval_required:
self.display_data_policy_approval = True
@api.onchange('internal_rules_approval_required')
def onchange_internal_rules_approval_required(self):
if self.internal_rules_approval_required:
self.display_internal_rules_approval = True

12
easy_my_coop/models/coop.py

@ -16,8 +16,6 @@ _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
@ -32,7 +30,13 @@ class subscription_request(models.Model):
_description = 'Subscription Request' _description = 'Subscription Request'
def get_required_field(self): def get_required_field(self):
return _REQUIRED
required_fields = _REQUIRED
company = self.env['res.company']._company_default_get()
if company.data_policy_approval_required:
required_fields.append('data_policy_approved')
if company.internal_rules_approval_required:
required_fields.append('internal_rules_approved')
return required_fields
@api.model @api.model
def create(self, vals): def create(self, vals):
@ -334,12 +338,10 @@ class subscription_request(models.Model):
data_policy_approved = fields.Boolean( data_policy_approved = fields.Boolean(
string='Data Policy Approved', string='Data Policy Approved',
default=False, default=False,
# required=True,
) )
internal_rules_approved = fields.Boolean( internal_rules_approved = fields.Boolean(
string='Approved Internal Rules', string='Approved Internal Rules',
default=False, default=False,
# required=True,
) )
_order = "id desc" _order = "id desc"

6
easy_my_coop/view/res_company_view.xml

@ -21,6 +21,12 @@
<field name="default_lang_id"/> <field name="default_lang_id"/>
<field name="board_representative"/> <field name="board_representative"/>
<field name="signature_scan"/> <field name="signature_scan"/>
<field name="display_data_policy_approval"/>
<field name="data_policy_approval_required"/>
<field name="data_policy_approval_text"/>
<field name="display_internal_rules_approval"/>
<field name="internal_rules_approval_required"/>
<field name="internal_rules_approval_text"/>
</group> </group>
</xpath> </xpath>
</field> </field>

95
easy_my_coop/view/subscription_template.xml

@ -240,31 +240,33 @@
<br/> <br/>
<div t-attf-class="form-group" >
<div id="data_policy_approved" t-if="display_data_policy" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="data_policy_approved">Privacy Policy</label> <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 class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="data_policy_approved"
t-att="{'required': 'required'} if data_policy_required else {}"
t-attf-value="#{data_policy_approved or ''}"/>
<t t-raw="data_policy_text"/>
</label>
</div>
</div> </div>
</div> </div>
<div t-attf-class="form-group" >
<div id="internal_rules_approved" t-if="display_internal_rules" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="internal_rules_approved">Internal Rules</label> <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 class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="internal_rules_approved"
t-att="{'required': 'required'} if internal_rules_required else {}"
t-attf-value="#{internal_rules_approved or ''}"/>
<t t-raw="internal_rules_text"/>
</label>
</div>
</div> </div>
</div> </div>
@ -537,31 +539,33 @@
<br/> <br/>
<div t-attf-class="form-group" >
<div id="data_policy_approved" t-if="display_data_policy" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="data_policy_approved">Privacy Policy</label> <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 class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="data_policy_approved"
t-att="{'required': 'required'} if data_policy_required else {}"
t-attf-value="#{data_policy_approved or ''}"/>
<t t-raw="data_policy_text"/>
</label>
</div>
</div> </div>
</div> </div>
<div t-attf-class="form-group" >
<div id="internal_rules_approved" t-if="display_internal_rules" t-attf-class="form-group" >
<label class="col-md-3 col-sm-4 control-label" for="internal_rules_approved">Internal Rules</label> <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 class="col-md-9 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox"
name="internal_rules_approved"
t-att="{'required': 'required'} if internal_rules_required else {}"
t-attf-value="#{internal_rules_approved or ''}"/>
<t t-raw="internal_rules_text"/>
</label>
</div>
</div> </div>
</div> </div>
@ -618,15 +622,4 @@
</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