From bb4324a69e898a65a35fcbdd3801cec99f426a22 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Mon, 22 Aug 2022 14:18:41 +0000 Subject: [PATCH] [FIX] base: fix t-field with empty value/default value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since odoo/odoo#97347 we support default values for `t-field` directives. However this causes some issues in the case where we have: no value, no default value AND force_display is true. This is because the indentation for one of the lines in the compiled code was not correct. (full explanation here: https://github.com/odoo/odoo/pull/97347#issuecomment-1222430659) closes odoo/odoo#98714 X-original-commit: 2b605d3ccd55dc4f5b1ad44439411542e5b04b31 Signed-off-by: Rémy Voet Signed-off-by: William Braeckman (wbr) --- odoo/addons/base/tests/test_qweb.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/odoo/addons/base/tests/test_qweb.py b/odoo/addons/base/tests/test_qweb.py index 28341bcda7a..d90d161a978 100644 --- a/odoo/addons/base/tests/test_qweb.py +++ b/odoo/addons/base/tests/test_qweb.py @@ -143,6 +143,24 @@ class TestQWebTField(TransactionCase): }) self.assertEqual(str(rendered.strip()), result.strip()) + def test_no_value_no_default_value(self): + # no value, no default value with attributes on t-field + t = self.env['ir.ui.view'].create({ + 'name': 'test', + 'type': 'qweb', + 'arch_db': ''' +
+ ''', + }) + result = """ +
+ """ + # inherit_branding puts attribute on the field tag as well as force the display in case the field is empty + rendered = self.env['ir.qweb'].with_context(inherit_branding=True)._render(t.id, { + 'record': self.env['res.partner'].new({}), + }) + self.assertEqual(str(rendered.strip()), result.strip()) + class TestQWebNS(TransactionCase): def test_render_static_xml_with_namespace(self):