I want to add a new field called about_me to the portal module but when I click the confirm button, an "Unknown field" error appears, could there be something missing in the inhertit template method?
The controller will check if the fields present in post
are also present in MANDATORY_BILLING_FIELDS
or in OPTIONAL_BILLING_FIELDS
@route(['/my/account'], type='http', auth='user', website=True)
def account(self, redirect=None, **post):
...
if post and request.httprequest.method == 'POST':
error, error_message = self.details_form_validate(post)
The part of details_form_validate
that will return the error message:
def details_form_validate(self, data):
...
unknown = [k for k in data if k not in self.MANDATORY_BILLING_FIELDS + self.OPTIONAL_BILLING_FIELDS]
if unknown:
error['common'] = 'Unknown field'
error_message.append("Unknown field '%s'" % ','.join(unknown))
return error, error_message
After that, it will check if there is no error to write values and redirect you to /my/home
or the one defined by the redirect
parameter.
To avoid this issue just add your field to OPTIONAL_BILLING_FIELDS
:
from odoo.addons.portal.controllers.portal import CustomerPortal
CustomerPortal.OPTIONAL_BILLING_FIELDS.append('about_me')