diff options
| author | Simon Lejeune <sle@openerp.com> | 2017-01-06 15:05:28 +0100 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2017-03-09 13:19:53 +0100 |
| commit | 4923c8f1d47bd1bec5897a8b9526b82da81a2fda (patch) | |
| tree | ae81fdb9900622a2d2a3c14066be4604eb9ca1cb /odoo/addons/base/tests/test_qweb.py | |
| parent | 787e1037cdca48fe361ae65d790056a3d57e6b67 (diff) | |
[ADD] QWeb: namespace support in static attribute
This is needed for the mexican localization. Support of ns prefixed
attribute in dynamic attributes is not supported.
Diffstat (limited to 'odoo/addons/base/tests/test_qweb.py')
| -rw-r--r-- | odoo/addons/base/tests/test_qweb.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/odoo/addons/base/tests/test_qweb.py b/odoo/addons/base/tests/test_qweb.py index 67cb98ffcb7..dcf41b092d6 100644 --- a/odoo/addons/base/tests/test_qweb.py +++ b/odoo/addons/base/tests/test_qweb.py @@ -168,6 +168,21 @@ class TestQWebNS(TransactionCase): self.assertEquals(dedent_and_strip(view1.render()), dedent_and_strip(expected_result)) + def test_render_static_xml_with_namespace_3(self): + expected_result = """ + <cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd"></cfdi:Comprobante> + """ + + view1 = self.env['ir.ui.view'].create({ + 'name': "dummy", + 'type': 'qweb', + 'arch': """ + <t t-name="base.dummy">%s</t> + """ % expected_result + }) + + self.assertEquals(dedent_and_strip(view1.render()), dedent_and_strip(expected_result)) + 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. @@ -325,6 +340,36 @@ class TestQWebNS(TransactionCase): self.assertEquals(dedent_and_strip(view1.render(dict(version_id=1.0))), dedent_and_strip(expected_result)) + def test_render_static_xml_with_namespaced_attributes(self): + view1 = self.env['ir.ui.view'].create({ + 'name': "dummy", + 'type': 'qweb', + 'arch': """ + <t t-name="base.dummy"> + <cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd">abc</cfdi:Comprobante> + </t> + """ + }) + + expected_result = """<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd">abc</cfdi:Comprobante>""" + + self.assertEquals(dedent_and_strip(view1.render()), dedent_and_strip(expected_result)) + + def test_render_dynamic_xml_with_namespaced_attributes(self): + view1 = self.env['ir.ui.view'].create({ + 'name': "dummy", + 'type': 'qweb', + 'arch': """ + <t t-name="base.dummy"> + <cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd" t-esc="'abc'"/> + </t> + """ + }) + + expected_result = """<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd">abc</cfdi:Comprobante>""" + + self.assertEquals(dedent_and_strip(view1.render()), dedent_and_strip(expected_result)) + def test_render_static_xml_with_t_call(self): view1 = self.env['ir.ui.view'].create({ 'name': "dummy", |
