[FIX] t-ignore should remove injected sub-view branding below the ignore flag
bzr revid: xmo@openerp.com-20140225114706-j8q44cubs59tuwby
This commit is contained in:
parent
a949f024a1
commit
a67cd4c049
|
@ -743,6 +743,11 @@ class view(osv.osv):
|
||||||
def distribute_branding(self, e, branding=None, parent_xpath='',
|
def distribute_branding(self, e, branding=None, parent_xpath='',
|
||||||
index_map=misc.ConstantMapping(1)):
|
index_map=misc.ConstantMapping(1)):
|
||||||
if e.get('t-ignore') or e.tag == 'head':
|
if e.get('t-ignore') or e.tag == 'head':
|
||||||
|
# remove any view branding possibly injected by inheritance
|
||||||
|
attrs = set(MOVABLE_BRANDING)
|
||||||
|
for descendant in e.iterdescendants(tag=etree.Element):
|
||||||
|
if not attrs.intersection(descendant.attrib): continue
|
||||||
|
self._pop_view_branding(descendant)
|
||||||
# TODO: find a better name and check if we have a string to boolean helper
|
# TODO: find a better name and check if we have a string to boolean helper
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -533,7 +533,7 @@ class TestTemplating(ViewCase):
|
||||||
'data-oe-xpath': '/xpath/item/content[1]',
|
'data-oe-xpath': '/xpath/item/content[1]',
|
||||||
}), {
|
}), {
|
||||||
'order': '2',
|
'order': '2',
|
||||||
'data-oe-source-id': "159"
|
'data-oe-source-id': str(id)
|
||||||
}),
|
}),
|
||||||
E.item({
|
E.item({
|
||||||
'order': '1',
|
'order': '1',
|
||||||
|
@ -563,9 +563,52 @@ class TestTemplating(ViewCase):
|
||||||
|
|
||||||
self.assertEqual(arch, E.root(E.item(E.span({'t-esc': "foo"}))))
|
self.assertEqual(arch, E.root(E.item(E.span({'t-esc': "foo"}))))
|
||||||
|
|
||||||
@unittest2.expectedFailure
|
|
||||||
def test_ignore_unbrand(self):
|
def test_ignore_unbrand(self):
|
||||||
self.fail("Branding should be removed from subviews of a t-ignore (?)")
|
Views = self.registry('ir.ui.view')
|
||||||
|
id = Views.create(self.cr, self.uid, {
|
||||||
|
'name': "Base view",
|
||||||
|
'type': 'qweb',
|
||||||
|
'arch': """<root>
|
||||||
|
<item order="1" t-ignore="true">
|
||||||
|
<t t-esc="foo"/>
|
||||||
|
</item>
|
||||||
|
</root>"""
|
||||||
|
})
|
||||||
|
id2 = Views.create(self.cr, self.uid, {
|
||||||
|
'name': "Extension",
|
||||||
|
'type': 'qweb',
|
||||||
|
'inherit_id': id,
|
||||||
|
'arch': """<xpath expr="//item[@order='1']" position="inside">
|
||||||
|
<item order="2">
|
||||||
|
<content t-att-href="foo">bar</content>
|
||||||
|
</item>
|
||||||
|
</xpath>"""
|
||||||
|
})
|
||||||
|
|
||||||
|
arch_string = Views.read_combined(
|
||||||
|
self.cr, self.uid, id, fields=['arch'],
|
||||||
|
context={'inherit_branding': True})['arch']
|
||||||
|
|
||||||
|
arch = ET.fromstring(arch_string)
|
||||||
|
Views.distribute_branding(arch)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
arch,
|
||||||
|
E.root(
|
||||||
|
E.item(
|
||||||
|
{'t-ignore': 'true', 'order': '1'},
|
||||||
|
E.t({'t-esc': 'foo'}),
|
||||||
|
E.item(
|
||||||
|
{'order': '2', 'data-oe-source-id': str(id)},
|
||||||
|
E.content(
|
||||||
|
{'t-att-href': 'foo'},
|
||||||
|
"bar")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"t-ignore should apply to injected sub-view branding, not just to"
|
||||||
|
" the main view's"
|
||||||
|
)
|
||||||
|
|
||||||
class test_views(ViewCase):
|
class test_views(ViewCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue