Browse Source

[IMP] add birthday and gender fields

pull/52/head
houssine 5 years ago
parent
commit
d1cf2353e0
  1. 11
      easy_my_coop_website_portal/controllers/main.py
  2. 19
      easy_my_coop_website_portal/views/easy_my_coop_website_portal_templates.xml

11
easy_my_coop_website_portal/controllers/main.py

@ -15,7 +15,9 @@ from odoo.addons.payment.controllers.portal import PaymentProcessing
class CooperatorPortalAccount(CustomerPortal):
CustomerPortal.MANDATORY_BILLING_FIELDS.append("iban")
CustomerPortal.MANDATORY_BILLING_FIELDS.extend(["iban",
"birthdate_date",
"gender"])
def _prepare_portal_layout_values(self):
values = super(CooperatorPortalAccount,
@ -25,6 +27,7 @@ class CooperatorPortalAccount(CustomerPortal):
# need to check if the partner is a "contact" or not.
partner = request.env.user.partner_id
coop = partner.commercial_partner_id
partner_obj = request.env['res.partner']
coop_bank = request.env['res.partner.bank'].sudo().search(
[('partner_id', 'in', [coop.id])],
limit=1
@ -42,12 +45,16 @@ class CooperatorPortalAccount(CustomerPortal):
iban = ''
if partner.bank_ids:
iban = partner.bank_ids[0].acc_number
fields_desc = partner_obj.sudo().fields_get(['gender'])
values.update({
'coop': coop,
'coop_bank': coop_bank,
'capital_request_count': capital_request_count,
'invoice_count': invoice_count,
'iban': iban
'iban': iban,
'genders': fields_desc['gender']['selection']
})
return values

19
easy_my_coop_website_portal/views/easy_my_coop_website_portal_templates.xml

@ -8,9 +8,24 @@
<odoo>
<template id="portal_my_details_emc" inherit_id="portal.portal_my_details" name="Portal user details">
<xpath expr="//input[@name='phone']/.." position="after">
<div t-attf-class="form-group #{error.get('gender') and 'o_has_error' or ''} col-xl-6">
<label class="col-form-label" for="gender">Gender</label>
<select name="gender" t-attf-class="form-control #{error.get('gender') or ''}">
<option value=""></option>
<t t-foreach="genders or []" t-as="item">
<option t-att-value="item[0]" t-att-selected="item[0] == partner.gender">
<t t-esc="item[1]" />
</option>
</t>
</select>
</div>
<div t-attf-class="form-group #{error.get('birthdate_date') and 'o_has_error' or ''} col-xl-6">
<label class="col-form-label" for="birthdate_date">Birthdate</label>
<input type="date" name="birthdate_date" t-attf-class="form-control #{error.get('birthdate_date') or ''}" t-att-value="birthdate_date or partner.birthdate_date" />
</div>
<div t-attf-class="form-group #{error.get('iban') and 'o_has_error' or ''} col-xl-6">
<label class="col-form-label" for="phone">Iban</label>
<input type="input" name="iban" t-attf-class="form-control #{error.get('iban') and 'is-invalid' or ''}" t-att-value="iban" />
<label class="col-form-label" for="iban">Iban</label>
<input type="input" name="iban" t-attf-class="form-control #{error.get('iban') or ''}" t-att-value="iban" />
</div>
</xpath>
</template>

Loading…
Cancel
Save