diff --git a/odoo/addons/base/models/qweb.py b/odoo/addons/base/models/qweb.py index 5786111cdf3..dab3f39e37f 100644 --- a/odoo/addons/base/models/qweb.py +++ b/odoo/addons/base/models/qweb.py @@ -939,10 +939,9 @@ class QWeb(object): body = [] if el.getchildren(): for item in el: - # ignore comments & processing instructions - if isinstance(item, etree._Comment): - continue - body.extend(self._compile_node(item, options, indent)) + if not isinstance(item, etree._Comment): + body.extend(self._compile_node(item, options, indent)) + # comments can also contains tail text if item.tail is not None: self._appendText(item.tail, options) return body diff --git a/odoo/addons/base/tests/test_qweb.py b/odoo/addons/base/tests/test_qweb.py index e754dacf403..f0d26e443c3 100644 --- a/odoo/addons/base/tests/test_qweb.py +++ b/odoo/addons/base/tests/test_qweb.py @@ -5,6 +5,7 @@ import collections import json import os.path import re +import markupsafe from lxml import etree, html from lxml.builder import E @@ -1262,3 +1263,26 @@ class TestEmptyLines(TransactionCase): self.assertTrue(re.compile('^\s+\n').match(rendered)) self.assertTrue(re.compile('\n\s+\n').match(rendered)) + +class TestQWebMisc(TransactionCase): + def test_render_comment_tail(self): + """ Test the rendering of a tail text, near a comment. + """ + + view1 = self.env['ir.ui.view'].create({ + 'name': "dummy", + 'type': "qweb", + 'arch': """ + + + + Text 1 + + Text 2 + ok + + """ + }) + emptyline = '\n ' + expected = markupsafe.Markup('Text 1' + emptyline + 'Text 2' + emptyline + 'ok') + self.assertEqual(view1._render(), expected)