Odoo18-Base/addons/l10n_mx/controllers/portal.py

29 lines
1.1 KiB
Python
Raw Permalink Normal View History

2025-03-10 10:52:11 +07:00
from odoo.addons.portal.controllers import portal
from odoo.http import request
class CustomerPortal(portal.CustomerPortal):
def _get_mandatory_fields(self):
# EXTENDS 'portal'
try:
country_id = int(request.env.context.get('portal_form_country_id', ''))
except ValueError:
country_id = None
mandatory_fields = super()._get_mandatory_fields()
if country_id and request.env['res.country'].sudo().browse(country_id).code == 'MX':
mandatory_fields += ['zipcode', 'vat']
return mandatory_fields
def _get_optional_fields(self):
# EXTENDS 'portal'
try:
country_id = int(request.env.context.get('portal_form_country_id', ''))
except ValueError:
country_id = None
optional_fields = super()._get_optional_fields()
if country_id and request.env['res.country'].sudo().browse(country_id).code == 'MX':
optional_fields = [field for field in optional_fields if field not in ['zipcode', 'vat']]
return optional_fields