[FIX] base: groups also distribute branding

When there is a:

`groups="..."`

on a qweb view, when you edit the view with the editor then save all
groups will be removed since they are processed (so either we don't see
`groups` in the rendered view, or we don't see the element itself).

With this change, the "where should this part be saved when edited"
branding will be distributed to elements with `groups` attribute.

Added test without change failed with:

  AssertionError: {'data-oe-model': 'ir.ui.view', 'data-oe-id': '827',
                   'data-oe-field': 'arch'} != {}

because branding was added to `root` tag before change.

opw-2253576
closes #51489

closes odoo/odoo#51548

X-original-commit: c77bd5b043b7d2a795d0fc70c8e83b308a357224
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2020-05-19 14:07:00 +00:00
parent c5d3a109f5
commit 86ecb86069
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -1611,7 +1611,7 @@ actual arch.
:rtype: boolean
"""
return any(
(attr in ('data-oe-model', 'group') or (attr.startswith('t-')))
(attr in ('data-oe-model', 'groups') or (attr.startswith('t-')))
for attr in node.attrib
)
+21
View File
@@ -903,6 +903,27 @@ class TestTemplating(ViewCase):
)
)
def test_branding_attribute_groups(self):
view = self.View.create({
'name': "Base View",
'type': 'qweb',
'arch': """<root>
<item groups="base.group_no_one"/>
</root>""",
})
arch_string = view.with_context(inherit_branding=True).read_combined(['arch'])['arch']
arch = etree.fromstring(arch_string)
self.View.distribute_branding(arch)
self.assertEqual(arch, E.root(E.item({
'groups': 'base.group_no_one',
'data-oe-model': 'ir.ui.view',
'data-oe-id': str(view.id),
'data-oe-field': 'arch',
'data-oe-xpath': '/root[1]/item[1]',
})))
def test_call_no_branding(self):
view = self.View.create({
'name': "Base View",