diff --git a/odoo/addons/base/models/qweb.py b/odoo/addons/base/models/qweb.py index b4c13c6a8ea..878d46209f2 100644 --- a/odoo/addons/base/models/qweb.py +++ b/odoo/addons/base/models/qweb.py @@ -984,7 +984,8 @@ class QWeb(object): else: # Etree will remove the ns prefixes indirection by inlining the corresponding # nsmap definition into the tag attribute. Restore the tag and prefix here. - # Note: we do not support namespace dynamic attributes. + # Note: we do not support namespace dynamic attributes, we need a default URI + # on the root and use attribute directive t-att="{'xmlns:example': value}". unqualified_el_tag = etree.QName(el.tag).localname el_tag = unqualified_el_tag if el.prefix: diff --git a/odoo/addons/base/tests/test_qweb.py b/odoo/addons/base/tests/test_qweb.py index ddfe1c609d1..05c97519ce3 100644 --- a/odoo/addons/base/tests/test_qweb.py +++ b/odoo/addons/base/tests/test_qweb.py @@ -207,6 +207,89 @@ class TestQWebNS(TransactionCase): self.assertEqual(etree.fromstring(view1._render()), etree.fromstring(expected_result)) + def test_render_static_xml_with_namespace_dynamic(self): + """ Test the rendering on a namespaced view with dynamic URI (need default namespace uri). + """ + tempate = u""" + + + + Apples + Bananas + + + + """ + expected_result = u""" + + + + Apples + Bananas + + + + """ + + values = dict(h1="http://www.example.org/table", h2="http://www.w3.org/TD/html4/") + + view1 = self.env['ir.ui.view'].create({ + 'name': "dummy", + 'type': 'qweb', + 'arch': u""" + %s + """ % tempate + }) + + rendering = view1._render(values, engine='ir.qweb') + + self.assertEqual(etree.fromstring(rendering), etree.fromstring(expected_result % values)) + + def test_render_static_xml_with_namespace_dynamic_2(self): + """ Test the rendering on a namespaced view with dynamic URI (need default namespace uri). + Default URIs must be differents. + """ + tempate = u""" + + + + Apples + Bananas + + + + 80 + + + """ + expected_result = u""" + + + + Apples + Bananas + + + + 80 + + + """ + + values = dict(h1="http://www.example.org/table", h2="http://www.w3.org/TD/html4/", f="http://www.example.org/furniture") + + view1 = self.env['ir.ui.view'].create({ + 'name': "dummy", + 'type': 'qweb', + 'arch': u""" + %s + """ % tempate + }) + + rendering = view1._render(values, engine='ir.qweb') + + self.assertEqual(etree.fromstring(rendering), etree.fromstring(expected_result % values)) + def test_render_dynamic_xml_with_namespace_t_esc(self): """ Test that rendering a template containing a node having both an ns declaration and a t-esc attribute correctly handles the t-esc attribute and keep the ns declaration.