[FIX] website: prevent tb when using a background video as cover
Prior to this commit, when using a background video on the cover of the website_slides homepage (/slides), after saving, a traceback would occur and the video would not be displayed. Steps to reproduce: - Install website_slide - Go to /slides - Enter edit mode - Change the cover of the page by a video - Save - Traceback The reason for that is that the cover snippet used on the homepage of elearning is the root of an XPath instead of its own oe_structure. (This was changed in 16.0) [1] made it so that the style and class attributes are saved but did not save any data attributes needed for the background-video widget to work. This commit adds those data attributes. [1]: https://github.com/odoo/odoo/commit/5b252215dc375526af87c31a32256dd1a9582f02 opw-3063043 closes odoo/odoo#107577 X-original-commit: 86dc4d4349d033c95c0e04e8c173f63e5e2044ed Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
@@ -117,6 +117,10 @@ class IrUiView(models.Model):
|
||||
return False
|
||||
return all(self._are_archs_equal(arch1, arch2) for arch1, arch2 in zip(arch1, arch2))
|
||||
|
||||
@api.model
|
||||
def _get_allowed_root_attrs(self):
|
||||
return ['style', 'class']
|
||||
|
||||
def replace_arch_section(self, section_xpath, replacement, replace_tail=False):
|
||||
# the root of the arch section shouldn't actually be replaced as it's
|
||||
# not really editable itself, only the content truly is editable.
|
||||
@@ -132,7 +136,7 @@ class IrUiView(models.Model):
|
||||
root.text = replacement.text
|
||||
|
||||
# We need to replace some attrib for styles changes on the root element
|
||||
for attribute in ('style', 'class'):
|
||||
for attribute in self._get_allowed_root_attrs():
|
||||
if attribute in replacement.attrib:
|
||||
root.attrib[attribute] = replacement.attrib[attribute]
|
||||
|
||||
|
||||
@@ -484,6 +484,14 @@ class View(models.Model):
|
||||
self = website_specific_view
|
||||
super(View, self).save(value, xpath=xpath)
|
||||
|
||||
@api.model
|
||||
def _get_allowed_root_attrs(self):
|
||||
# Related to these options:
|
||||
# background-video, background-shapes, parallax
|
||||
return super()._get_allowed_root_attrs() + [
|
||||
'data-bg-video-src', 'data-shape', 'data-scroll-background-ratio',
|
||||
]
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Snippet saving
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user