From 7c4628b1f4853494fd4bb3bf00cd031d12bcd945 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 3 Dec 2019 09:29:16 +0000 Subject: [PATCH] [FIX] base: render with page-break => ok encoding If we have eg. a report with a page break (eg. `Print On New Page` enabled on a financial report section) the encoding is broken. The reason is that lxml.html fragments_fromstring function accepts text string (OK in unicode) or bytestring => the encoding will be guessed (by chardet library) if guess_charset argument is set to true. So since we do not pass guess_charset option, the encoding is not recognized. In this changeset, we give a text string to the fragments_fromstring function since it seems that all our input should be in UTF-8. note: lxml.html itself uses html5lib.HTMLParser parseFragment that takes a charset argument, but there is no interface through fragments_fromstring to specify the charset. opw-2146715 closes #41255 closes odoo/odoo#41289 X-original-commit: 1d3d517aad08887970e4ba2d9290e260faacae2d Signed-off-by: Nicolas Lempereur (nle) --- odoo/addons/base/models/ir_qweb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_qweb.py b/odoo/addons/base/models/ir_qweb.py index 07fe2d1592f..5c45c91060f 100644 --- a/odoo/addons/base/models/ir_qweb.py +++ b/odoo/addons/base/models/ir_qweb.py @@ -60,7 +60,7 @@ class IrQWeb(models.AbstractModel, QWeb): if b'data-pagebreak=' not in result: return result - fragments = html.fragments_fromstring(result) + fragments = html.fragments_fromstring(result.decode('utf-8')) for fragment in fragments: for row in fragment.iterfind('.//tr[@data-pagebreak]'):