From c996a1a5f48c5c86f9c2b42e07a3a2aaae4dbb80 Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Thu, 1 Feb 2024 14:14:48 +0000 Subject: [PATCH] [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) Signed-off-by: Antoine Vandevenne (anv) --- addons/website/models/website_form.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/models/website_form.py b/addons/website/models/website_form.py index cb4b4b141b5..074ebaf1770 100644 --- a/addons/website/models/website_form.py +++ b/addons/website/models/website_form.py @@ -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