[IMP] l10n_ec_website_sale: portal contact information
Currently, if a customer wants to edit his/her information from the Portal access, they cannot modify the information linked to EC. This commit aims to support Ecuadorian companies needed information when editing the portal contact information: - added "Identification Type" field - renamed "VAT" to "Identification Number" - make those 2 fields required closes odoo/odoo#142730 Task-id: 3620196 Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import main
|
||||
from . import portal
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.portal.controllers.portal import CustomerPortal
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class CustomerPortalEcuador(CustomerPortal):
|
||||
|
||||
def _is_ecuador_company(self):
|
||||
return request.env.company.country_code == 'EC'
|
||||
|
||||
def _get_mandatory_fields(self):
|
||||
# EXTEND 'portal'
|
||||
mandatory_fields = super()._get_mandatory_fields()
|
||||
|
||||
if self._is_ecuador_company():
|
||||
mandatory_fields.extend(('l10n_latam_identification_type_id', 'vat'))
|
||||
|
||||
return mandatory_fields
|
||||
|
||||
def _prepare_portal_layout_values(self):
|
||||
# EXTEND 'portal'
|
||||
portal_layout_values = super()._prepare_portal_layout_values()
|
||||
|
||||
if self._is_ecuador_company():
|
||||
partner = request.env.user.partner_id
|
||||
portal_layout_values.update({
|
||||
'identification': partner.l10n_latam_identification_type_id,
|
||||
'identification_types': request.env['l10n_latam.identification.type'].search(
|
||||
['|', ('country_id', '=', False), ('country_id.code', '=', 'EC')]),
|
||||
})
|
||||
|
||||
return portal_layout_values
|
||||
|
||||
def details_form_validate(self, data, partner_creation=False):
|
||||
# EXTEND 'portal'
|
||||
error, error_message = super().details_form_validate(data, partner_creation)
|
||||
|
||||
# sanitize identification value to make sure it's correctly written on the partner
|
||||
if self._is_ecuador_company() and data.get('l10n_latam_identification_type_id'):
|
||||
data['l10n_latam_identification_type_id'] = int(data['l10n_latam_identification_type_id'])
|
||||
|
||||
return error, error_message
|
||||
@@ -45,4 +45,22 @@
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template id="portal_my_details_fields" name="portal_my_details_fields" inherit_id="portal.portal_my_details_fields">
|
||||
<xpath expr="//input[@name='vat']/.." position="before">
|
||||
<t t-if="res_company.country_code == 'EC'">
|
||||
<div class="clearfix"/>
|
||||
<t t-call="l10n_ec_website_sale.partner_info"/>
|
||||
</t>
|
||||
</xpath>
|
||||
|
||||
<label for="vat" position="replace">
|
||||
<t t-if="res_company.country_id.code != 'EC'">$0</t>
|
||||
<t t-else="">
|
||||
<label class="col-form-label label-optional" for="vat">
|
||||
Identification Number
|
||||
</label>
|
||||
</t>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user