From 5941411376a9c7c17a92d0d01c8d04e3e171a93d Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Thu, 26 Oct 2023 11:02:04 +0000 Subject: [PATCH] [FIX] website: fix configurator pages with only one snippet This commit fixes a bug in page creation by the configurator. This only happened with pages containing only one snippet, like the "Pricing" page or the "Privacy Policy" page (default themes). Because of this bug, the snippet that should be placed in the page had its parent element "
" replaced with a "
", so the section options were no longer available in edit mode, such as background options, delete/duplicate/save the snippet, etc. When there was multiple snippets, it worked by chance: `
` was parsed as `
` using the etree lib. The web_editor `save` method then copied each children and put them in the targeted oe_structure. However, with only one snippet: `
` it was parsed as it is, then same: each children was copied and put in the targeted oe_structure... but the only child here is the `container`. Then the classes of the section were transferred on the oe_structure element. Steps to reproduce the bug: - Create a new website using the configurator. - Check the "Pricing" box in the list of features to create the "Pricing" page. - Once the website creation is complete, go to the "/pricing" page. - In edit mode, click on the "comparisons" snippet. - Bug: Some options are missing for the snippet, for example, it's not possible to delete the snippet or change its background. task-3570903 closes odoo/odoo#143049 X-original-commit: 68ffe065c6fa03874ee8c99b91ca317d1c2755a3 Signed-off-by: Quentin Smetz (qsm) --- addons/website/models/website.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 30aa9975ddf..25fa1641fae 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -702,7 +702,8 @@ class Website(models.Model): rendered_snippets.append(rendered_snippet) except ValueError as e: logger.warning(e) - page_view_id.save(value=''.join(rendered_snippets), xpath="(//div[hasclass('oe_structure')])[last()]") + page_view_id.save(value=f'
{"".join(rendered_snippets)}
', + xpath="(//div[hasclass('oe_structure')])[last()]") # Configure the images images = custom_resources.get('images', {})