diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2020-06-19 12:22:55 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2020-06-19 14:51:34 +0000 |
| commit | 4c4a0eab958e0486af48a8afa17e024d6d8864b7 (patch) | |
| tree | aaee2cd673fba149883c1a08e2287379ef63e855 /addons/web_editor/models | |
| parent | 8c5b47e8c3ed621a7ed81a8f951e5a414d6fa0da (diff) | |
[FIX] web{site,_editor}: oe_structure save clean data-oe-*
Since dd139948f004 when saving oe_structure for the first time, for eg.
a `<div class="oe_structure" id="oe_structure_part_1"/>` structure, when
edited we will create an inheriting view that fills it.
But this inheriting view would contain branding data and "data-note-id"
which would make this use case erroneous:
- edit page and fill oe_structure => data-note-id="1" saved on view
- edit page and add link in other oe_structure => error
This happen because the data-note-id refers to the editor of the
element currently being edited, since we saved it previously we get two
elements with `data-note-id="1"` and the code will just get the first
one which in reality could have not been in editing.
With this change, we strip the branding data on the parent element.
Without the change, added test failed with:
AssertionError: '<div class="oe_structure" data-test="1"
id="oe_structure_test" test="2">hello</div>' not found in
'<t t-name="dummy"><div class="oe_structure" data-test="1"
id="oe_structure_test" data-oe-id="55" test="2">hello</div>
</t>' :
saved element attributes are saved excluding branding ones
opw-2268836
closes #53321
closes odoo/odoo#53346
X-original-commit: 855438be92ee71d8f8d5afedd52459e149ec49f7
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/web_editor/models')
| -rw-r--r-- | addons/web_editor/models/ir_ui_view.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/web_editor/models/ir_ui_view.py b/addons/web_editor/models/ir_ui_view.py index a3bfd773a92..0897662f2af 100644 --- a/addons/web_editor/models/ir_ui_view.py +++ b/addons/web_editor/models/ir_ui_view.py @@ -11,6 +11,8 @@ from odoo import api, models _logger = logging.getLogger(__name__) +EDITING_ATTRIBUTES = ['data-oe-model', 'data-oe-id', 'data-oe-field', 'data-oe-xpath', 'data-note-id'] + class IrUiView(models.Model): _inherit = 'ir.ui.view' @@ -67,7 +69,8 @@ class IrUiView(models.Model): arch = etree.Element('data') xpath = etree.Element('xpath', expr="//*[hasclass('oe_structure')][@id='{}']".format(el.get('id')), position="replace") arch.append(xpath) - structure = etree.Element(el.tag, attrib=el.attrib) + attributes = {k: v for k, v in el.attrib.items() if k not in EDITING_ATTRIBUTES} + structure = etree.Element(el.tag, attrib=attributes) structure.text = el.text xpath.append(structure) for child in el.iterchildren(tag=etree.Element): |
