Browse Source

[IMP] filling selection fields and signup for company

9.0_remove_national_register_number
houssine 5 years ago
parent
commit
39d69aab62
  1. 21
      easy_my_coop/controllers/AuthSignupHome.py
  2. 285
      easy_my_coop/view/auth_signup_template.xml

21
easy_my_coop/controllers/AuthSignupHome.py

@ -41,8 +41,7 @@ class AuthSignupHome(AuthSignupHome):
assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them." assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them."
supported_langs = [lang['code'] for lang supported_langs = [lang['code'] for lang
in lang_obj.sudo().search_read([], ['code'])] in lang_obj.sudo().search_read([], ['code'])]
if request.lang in supported_langs:
values['lang'] = request.lang
values['lang'] = qcontext.get("lang")
firstname = qcontext.get("firstname").title() firstname = qcontext.get("firstname").title()
lastname = qcontext.get('name').upper() lastname = qcontext.get('name').upper()
values['lastname'] = lastname values['lastname'] = lastname
@ -55,13 +54,24 @@ class AuthSignupHome(AuthSignupHome):
'acc_number': iban}) 'acc_number': iban})
request.cr.commit() request.cr.commit()
@http.route('/web/company_signup', type='http', auth='public', website=True)
def web_auth_company_signup(self, *args, **kw):
qcontext = request.params.copy()
qcontext['company'] = True
return self.web_auth_signup()
@http.route('/web/signup', type='http', auth='public', website=True) @http.route('/web/signup', type='http', auth='public', website=True)
def web_auth_signup(self, *args, **kw): def web_auth_signup(self, *args, **kw):
qcontext = self.get_auth_signup_qcontext() qcontext = self.get_auth_signup_qcontext()
users_obj = request.env["res.users"] users_obj = request.env["res.users"]
country_obj = request.env['res.country'] country_obj = request.env['res.country']
lang_obj = request.env['res.lang']
sub_req_obj = request.env['subscription.request'] sub_req_obj = request.env['subscription.request']
render_template = 'auth_signup.signup'
if qcontext.get('company', False):
render_template = 'auth_signup.company_signup'
if qcontext.get("login") != qcontext.get("confirm_email"): if qcontext.get("login") != qcontext.get("confirm_email"):
qcontext["error"] = _("The email address doesn't seem to match" qcontext["error"] = _("The email address doesn't seem to match"
" the email confirmation.") " the email confirmation.")
@ -87,14 +97,11 @@ class AuthSignupHome(AuthSignupHome):
else: else:
_logger.error(e.message) _logger.error(e.message)
qcontext['error'] = _("Could not create a new account.") qcontext['error'] = _("Could not create a new account.")
if not qcontext.get('raliment_point_id', False):
qcontext['raliment_point_id'] = 0
if not qcontext.get('delivery_point_id', False):
qcontext['delivery_point_id'] = 0
qcontext['langs'] = lang_obj.sudo().search([])
qcontext['countries'] = country_obj.sudo().search([]) qcontext['countries'] = country_obj.sudo().search([])
qcontext['country_id'] = '21' qcontext['country_id'] = '21'
fields_desc = sub_req_obj.sudo().fields_get(['company_type', 'gender']) fields_desc = sub_req_obj.sudo().fields_get(['company_type', 'gender'])
qcontext['company_types'] = fields_desc['company_type']['selection'] qcontext['company_types'] = fields_desc['company_type']['selection']
qcontext['genders'] = fields_desc['gender']['selection'] qcontext['genders'] = fields_desc['gender']['selection']
return request.render('auth_signup.signup', qcontext)
return request.render(render_template, qcontext)

285
easy_my_coop/view/auth_signup_template.xml

@ -1,24 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data> <data>
<!--<template id="easy_my_coop_login_layout" inherit_id="web.login_layout" name="Login Layout">
<xpath expr="//t[@t-set='head']" position="inside">
<!--<template id="easy_my_coop_login_layout" inherit_id="web.login_layout"
name="Login Layout"> <xpath expr="//t[@t-set='head']" position="inside">
<script type="text/javascript" src="/easy_my_coop/static/src/js/jquery.inputmask.bundle.js"></script> <script type="text/javascript" src="/easy_my_coop/static/src/js/jquery.inputmask.bundle.js"></script>
</xpath>
</template>-->
<template id="easy_my_coop_assets_backend" inherit_id="web.assets_backend">
</xpath> </template> -->
<template id="easy_my_coop_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside"> <xpath expr="." position="inside">
<script type="text/javascript" src="/easy_my_coop/static/src/js/jquery.inputmask.bundle.js"></script>
<script type="text/javascript"
src="/easy_my_coop/static/src/js/jquery.inputmask.bundle.js"></script>
</xpath> </xpath>
</template> </template>
<!--<template id="easy_my_coop_assets_common" inherit_id="web.assets_common"> <!--<template id="easy_my_coop_assets_common" inherit_id="web.assets_common">
<xpath expr="." position="inside">
<script type="text/javascript" src="/easy_my_coop/static/src/js/jquery.inputmask.bundle.js"></script>
</xpath>
</template>-->
<xpath expr="." position="inside"> <script type="text/javascript" src="/easy_my_coop/static/src/js/jquery.inputmask.bundle.js"></script>
</xpath> </template> -->
<template id="easy_my_coop_signup" inherit_id="auth_signup.signup" name="Easy My Coop Sign up login">
<template id="easy_my_coop_signup"
inherit_id="auth_signup.signup" name="Easy My Coop Sign up login">
<div t-attf-class="form-group">
<a class='btn btn-primary' href="/web/company_signup">You are a company? Click here.</a>
<br/>
</div>
<xpath expr="//t[@t-esc='error']/.." position="replace" /> <xpath expr="//t[@t-esc='error']/.." position="replace" />
<xpath expr="//input[@name='csrf_token']" position="after"> <xpath expr="//input[@name='csrf_token']" position="after">
<p class="alert alert-danger" t-if="error"> <p class="alert alert-danger" t-if="error">
@ -27,17 +31,23 @@
</xpath> </xpath>
</template> </template>
<template id="easy_my_coop_auth_fields" inherit_id="auth_signup.fields" name="Auth Signup/ResetPassword form fields">
<template id="easy_my_coop_auth_fields"
inherit_id="auth_signup.fields"
name="Auth Signup/ResetPassword form fields">
<xpath expr="//input[@name='name']/.." position="before"> <xpath expr="//input[@name='name']/.." position="before">
<div class="form-group field-name">
<div class="form-group field-login">
<label for="confirm_email" class="control-label">Confirm your email</label> <label for="confirm_email" class="control-label">Confirm your email</label>
<input type="text" name="confirm_email" t-att-value="confirm_email" id="confirm_email" class="form-control"
required="required" t-att-invisible="'invisible' if only_passwords else None" />
<input type="text" name="confirm_email"
t-att-value="confirm_email" id="confirm_email"
class="form-control" required="required"
t-att-invisible="'invisible' if only_passwords else None" />
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label for="firstname" class="control-label">Your firstname</label> <label for="firstname" class="control-label">Your firstname</label>
<input type="text" name="firstname" t-att-value="firstname" id="firstname" class="form-control" placeholder="John"
required="required" t-att-readonly="'readonly' if only_passwords else None" />
<input type="text" name="firstname" t-att-value="firstname"
id="firstname" class="form-control" placeholder="John"
required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div> </div>
</xpath> </xpath>
@ -52,58 +62,267 @@
<xpath expr="//input[@name='name']/.." position="after"> <xpath expr="//input[@name='name']/.." position="after">
<div class="form-group field-name"> <div class="form-group field-name">
<label for="gender" class="control-label">Your Gender</label> <label for="gender" class="control-label">Your Gender</label>
<select name="gender" id="gender" class="form-control" required="True" style="width:54%"
<select name="gender" id="gender" class="form-control"
required="True" style="width:54%"
t-att-disabled="'disabled' if only_passwords else None"> t-att-disabled="'disabled' if only_passwords else None">
<option value=""></option> <option value=""></option>
<t t-foreach="genders or []" t-as="type"> <t t-foreach="genders or []" t-as="type">
<option t-att-value="type[0]" t-att-selected="type[0] == gender"><t t-esc="type[1]"/></option>
<option t-att-value="type[0]"
t-att-selected="type[0] == gender">
<t t-esc="type[1]" />
</option>
</t> </t>
</select> </select>
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label class="control-label" for="birthdate">Birthdate</label> <label class="control-label" for="birthdate">Birthdate</label>
<input type="text" data-inputmask="'alias': 'date'" class="form-control mandatory-field" name="birthdate" required="True" t-attf-value="#{birthdate or ''}" placeholder="05/03/1978"/>
<input type="text" data-inputmask="'alias': 'date'"
class="form-control mandatory-field" name="birthdate"
required="True" t-attf-value="#{birthdate or ''}"
placeholder="05/03/1978" />
</div>
<div class="form-group field-name">
<label for="lang" class="control-label">Your Language</label>
<select name="lang" id="lang"
class="form-control" style="width:54%;" required="required"
t-att-disabled="'disabled' if only_passwords else None">
<option value="">Lang...</option>
<t t-foreach="langs or []" t-as="langue">
<option t-att-value="langue.code"
t-att-selected="langue.code == lang">
<t t-esc="langue.name" />
</option>
</t>
</select>
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label for="iban" class="control-label">IBAN number</label> <label for="iban" class="control-label">IBAN number</label>
<input type="text" name="iban" t-att-value="iban" id="iban" class="form-control" placeholder="BE645215965478"
required="required" t-att-readonly="'readonly' if only_passwords else None" />
<input type="text" name="iban" t-att-value="iban" id="iban"
class="form-control" placeholder="BE645215965478"
required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label for="phone" class="control-label">Your Phone</label> <label for="phone" class="control-label">Your Phone</label>
<input type="text" name="phone" t-att-value="phone" id="phone" class="form-control" placeholder="+325552365"
required="required" t-att-readonly="'readonly' if only_passwords else None" />
<input type="text" name="phone" t-att-value="phone"
id="phone" class="form-control" placeholder="+325552365"
required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label for="street" class="control-label">Your Street and Number</label> <label for="street" class="control-label">Your Street and Number</label>
<input type="text" name="street" t-att-value="street" id="street" class="form-control" placeholder="Rue de la transition, 63"
required="required" t-att-readonly="'readonly' if only_passwords else None" />
<input type="text" name="street" t-att-value="street"
id="street" class="form-control"
placeholder="Rue de la transition, 63" required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label for="zip_code" class="control-label">Your Zip Code</label> <label for="zip_code" class="control-label">Your Zip Code</label>
<input type="text" name="zip_code" t-att-value="zip_code" id="zip_code" class="form-control" placeholder="1040"
required="required" t-att-readonly="'readonly' if only_passwords else None" />
<input type="text" name="zip_code" t-att-value="zip_code"
id="zip_code" class="form-control" placeholder="1040"
required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label for="city" class="control-label">Your City</label> <label for="city" class="control-label">Your City</label>
<input type="text" name="city" t-att-value="city" id="city" class="form-control" placeholder="Bruxelles"
required="required" t-att-readonly="'readonly' if only_passwords else None" />
<input type="text" name="city" t-att-value="city" id="city"
class="form-control" placeholder="Bruxelles" required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div> </div>
<div class="form-group field-name"> <div class="form-group field-name">
<label for="country_id" class="control-label">Your Country</label> <label for="country_id" class="control-label">Your Country</label>
<select name="country_id" id="country_id" class="form-control" style="width:54%;" required="required"
<select name="country_id" id="country_id"
class="form-control" style="width:54%;" required="required"
t-att-disabled="'disabled' if only_passwords else None"> t-att-disabled="'disabled' if only_passwords else None">
<option value="">Country...</option> <option value="">Country...</option>
<t t-foreach="countries or []" t-as="country"> <t t-foreach="countries or []" t-as="country">
<option t-att-value="country.id" t-att-selected="country.id == int(country_id)"><t t-esc="country.name"/></option>
<option t-att-value="country.id"
t-att-selected="country.id == int(country_id)">
<t t-esc="country.name" />
</option>
</t> </t>
</select> </select>
</div> </div>
</xpath> </xpath>
</template> </template>
<template id="company_signup" name="Company sign up login">
<t t-call="web.login_layout">
<form class="oe_signup_form" role="form" method="post"
t-if="not message">
<input type="hidden" name="csrf_token"
t-att-value="request.csrf_token()" />
<div t-attf-class="form-group" style="display: none;">
<label>
<input type="checkbox" t-att-value="is_company"
checked="checked" name="is_company" />
Is a company?
</label>
</div>
<p class="alert alert-danger" t-if="error">
<t t-esc="error" />
</p>
<div class="form-group field-name">
<label for="name" class="control-label">Company Name</label>
<input type="text" name="company_name" t-att-value="company_name" id="name"
class="form-control" placeholder="The Universal Cooperative"
required="required"
t-att-readonly="'readonly' if only_passwords else None"
t-att-autofocus="'autofocus' if login and not only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="name" class="control-label">Company register number</label>
<input type="text" name="company_register_number" t-att-value="company_register_number" id="company_register_number"
class="form-control" placeholder="0647980091"
required="required"
t-att-readonly="'readonly' if only_passwords else None"
t-att-autofocus="'autofocus' if login and not only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="name" class="control-label">Company email</label>
<input type="text" name="company_email" t-att-value="company_email" id="company_email"
class="form-control"
required="required"
t-att-readonly="'readonly' if only_passwords else None"
t-att-autofocus="'autofocus' if login and not only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="iban" class="control-label">IBAN number</label>
<input type="text" name="iban" t-att-value="iban" id="iban"
class="form-control" placeholder="BE645215965478"
required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="phone" class="control-label">Phone</label>
<input type="text" name="phone" t-att-value="phone"
id="phone" class="form-control" placeholder="+325552365"
required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div>
<div class="form-group">
<label>
Main Address
</label>
</div>
<div class="form-group field-name">
<label for="street" class="control-label">Street and Number</label>
<input type="text" name="street" t-att-value="street"
id="street" class="form-control"
placeholder="Rue de la transition, 63" required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="zip_code" class="control-label">Zip Code</label>
<input type="text" name="zip_code" t-att-value="zip_code"
id="zip_code" class="form-control" placeholder="1040"
required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="city" class="control-label">City</label>
<input type="text" name="city" t-att-value="city" id="city"
class="form-control" placeholder="Bruxelles" required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="country_id" class="control-label">Country</label>
<select name="country_id" id="country_id"
class="form-control" style="width:54%;" required="required"
t-att-disabled="'disabled' if only_passwords else None">
<option value="">Country...</option>
<t t-foreach="countries or []" t-as="country">
<option t-att-value="country.id"
t-att-selected="country.id == int(country_id)">
<t t-esc="country.name" />
</option>
</t>
</select>
</div>
<!-- <br/>-->
<div class="form-group field-name">
<label>
Contact Person
</label>
</div>
<div class="form-group field-login">
<label for="login" class="control-label">Your Email</label>
<input type="text" name="login" t-att-value="login"
id="login" class="form-control" autofocus="autofocus"
autocapitalize="off" required="required"
t-att-readonly="'readonly' if only_passwords else None" />
</div>
<div class="form-group field-login">
<label for="confirm_email" class="control-label">Confirm your email</label>
<input type="text" name="confirm_email"
t-att-value="confirm_email" id="confirm_email"
class="form-control" required="required"
t-att-invisible="'invisible' if only_passwords else None" />
</div>
<div class="form-group field-name">
<label for="gender" class="control-label">Gender</label>
<select name="gender" id="gender" class="form-control"
required="True" style="width:54%"
t-att-disabled="'disabled' if only_passwords else None">
<option value=""></option>
<t t-foreach="company_types or []" t-as="type">
<option t-att-value="type[0]"
t-att-selected="type[0] == gender">
<t t-esc="type[1]" />
</option>
</t>
</select>
</div>
<div class="form-group field-name">
<label class="control-label" for="birthdate">Birthdate</label>
<input type="text" data-inputmask="'alias': 'date'"
class="form-control mandatory-field" name="birthdate"
required="True" t-attf-value="#{birthdate or ''}"
placeholder="05/03/1978" />
</div>
<div class="form-group field-name">
<label for="lang" class="control-label">Your Language</label>
<select name="lang" id="lang"
class="form-control" style="width:54%;" required="required"
t-att-disabled="'disabled' if only_passwords else None">
<option value="">Lang...</option>
<t t-foreach="langs or []" t-as="langue">
<option t-att-value="langue.code"
t-att-selected="langue.code == lang">
<t t-esc="langue.name" />
</option>
</t>
</select>
</div>
<div class="form-group field-password">
<label for="password" class="control-label">Password</label>
<input type="password" name="password" id="password"
class="form-control" required="required"
t-att-autofocus="'autofocus' if only_passwords else None" />
</div>
<div class="form-group field-confirm_password">
<label for="confirm_password" class="control-label">Confirm Password</label>
<input type="password" name="confirm_password"
id="confirm_password" class="form-control" required="required" />
</div>
<input type="hidden" name="redirect" t-att-value="redirect" />
<input type="hidden" name="token" t-att-value="token" />
<div class="clearfix oe_login_buttons">
<a t-attf-href="/web/login?{{ keep_query() }}"
class="btn btn-link pull-right">Back to Login</a>
<button type="submit" class="btn btn-primary pull-left">Sign up</button>
</div>
</form>
</t>
</template>
</data> </data>
</odoo> </odoo>
Loading…
Cancel
Save