[FIX] website: filter out JSON fields from authorized fields in forms
Issue: Possible to reproduce in 17.0: when adding a new field to the website form of the "Extra Info" page in the eCommerce, a traceback is raised (`OwlError: Missing template: "website.form_field_json"`) when the user selects "Delivery Point Address" (`sale.order.access_point_address`). Explanation: JSON fields (which exist since [1]) are not supported as selectable types in website forms, and they should not be because customers would not be able to properly fill them out. Fix: Filter out all JSON fields from the list of authorized fields in website forms; they will not appear in the list of selectable types anymore. [1]: https://github.com/odoo/odoo/commit/7eeba9d205d2dace571b5d0895ddba6290a512db opw-3596713 closes odoo/odoo#152545 X-original-commit: 28c3eb5878ad6f3d40a096803f3ba4aef5ef7937 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
@@ -64,14 +64,14 @@ class website_form_model(models.Model):
|
||||
for field in [f for f in fields_get if f in default_values]:
|
||||
fields_get[field]['required'] = False
|
||||
|
||||
# Remove readonly and magic fields
|
||||
# Remove readonly, JSON, and magic fields
|
||||
# Remove string domains which are supposed to be evaluated
|
||||
# (e.g. "[('product_id', '=', product_id)]")
|
||||
for field in list(fields_get):
|
||||
if 'domain' in fields_get[field] and isinstance(fields_get[field]['domain'], str):
|
||||
del fields_get[field]['domain']
|
||||
if fields_get[field].get('readonly') or field in models.MAGIC_COLUMNS or \
|
||||
fields_get[field]['type'] in ['many2one_reference', 'properties']:
|
||||
fields_get[field]['type'] in ['many2one_reference', 'properties', 'json']:
|
||||
del fields_get[field]
|
||||
|
||||
return fields_get
|
||||
|
||||
Reference in New Issue
Block a user