[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 "<section>" replaced with a "<div>", 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: `<section></section><section></section>` was parsed as `<div><section></section><section></section></div>` 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: `<section><div class="container"></div></section>` 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) <qsm@odoo.com>
This commit is contained in:
@@ -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'<div class="oe_structure">{"".join(rendered_snippets)}</div>',
|
||||
xpath="(//div[hasclass('oe_structure')])[last()]")
|
||||
|
||||
# Configure the images
|
||||
images = custom_resources.get('images', {})
|
||||
|
||||
Reference in New Issue
Block a user