From c62a75a5f3eb08f5fefe69706858a438361cb73d Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 23 Jan 2015 12:47:04 +0100 Subject: [PATCH] [FIX] report: line splitting compatible with reportlab > 3.0 While keeping the compatibility for reportlab 2.5. Splitting the text node on line breaks '\n' leaded to orphans ending tags, like '', which is regarded by reportlab 3.0 as a paragraph, and reportlab therefore surrounded these tags by tags, which leaded to not syntax correct html like To test this patch: - While having reportlab > 3.0 - Create a rml report containing (at least) '\n' - Then print the report. It must not crash (obviously) --- openerp/report/render/rml2pdf/trml2pdf.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py index 61da2973a9c..42908409644 100644 --- a/openerp/report/render/rml2pdf/trml2pdf.py +++ b/openerp/report/render/rml2pdf/trml2pdf.py @@ -768,15 +768,10 @@ class _rml_flowable(object): style = self.styles.para_style_get(node) if extra_style: style.__dict__.update(extra_style) - result = [] - tag_text = '' - plain_text = '' - for i in self._textual(node).split('\n'): - instance = platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))) - plain_text += instance.getPlainText().strip() - tag_text += instance.text.strip() - result.append(instance) - if LooseVersion(reportlab.Version) > LooseVersion('3.0') and not plain_text and tag_text: + text_node = self._textual(node).strip().replace('\n\n', '\n').replace('\n', '
') + instance = platypus.Paragraph(text_node, style, **(utils.attr_get(node, [], {'bulletText':'str'}))) + result = [instance] + if LooseVersion(reportlab.Version) > LooseVersion('3.0') and not instance.getPlainText().strip() and instance.text.strip(): result.append(platypus.Paragraph(' 
', style, **(utils.attr_get(node, [], {'bulletText': 'str'})))) return result elif node.tag=='barCode':