Skip to content

Commit

Permalink
[FIX] report: line splitting compatible with reportlab > 3.0
Browse files Browse the repository at this point in the history
While keeping the compatibility for reportlab 2.5.

Splitting the text node on line breaks '\n' leaded to orphans ending tags,
like '</font>', which is regarded by reportlab 3.0 as a paragraph,
and reportlab therefore surrounded these tags by <para> tags,
which leaded to not syntax correct html like
<para></font></para>

To test this patch:
 - While having reportlab > 3.0
 - Create a rml report containing (at least) '<font>\n</font>'
 - Then print the report. It must not crash (obviously)
  • Loading branch information
beledouxdenis committed Jan 23, 2015
1 parent d5c7234 commit c62a75a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions openerp/report/render/rml2pdf/trml2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,10 @@ def _flowable(self, node, extra_style=None):
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', '<br/>')
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('&nbsp;<br/>', style, **(utils.attr_get(node, [], {'bulletText': 'str'}))))
return result
elif node.tag=='barCode':
Expand Down

0 comments on commit c62a75a

Please sign in to comment.