Skip to content

Commit

Permalink
Add hook to extend the way different PDFs are merged together
Browse files Browse the repository at this point in the history
  • Loading branch information
grindtildeath committed Sep 24, 2018
1 parent ef0f955 commit 740d5ab
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions odoo/addons/base/ir/ir_actions_report.py
Expand Up @@ -546,18 +546,21 @@ def close_streams(streams):
streams.append(io.BytesIO(content))

# Build the final pdf.
result = self._merge_pdfs(streams)

# We have to close the streams after PdfFileWriter's call to write()
close_streams(streams)
return result

def _merge_pdfs(self, streams):
writer = PdfFileWriter()
for stream in streams:
reader = PdfFileReader(stream)
writer.appendPagesFromReader(reader)
result_stream = io.BytesIO()
streams.append(result_stream)
writer.write(result_stream)
result = result_stream.getvalue()

# We have to close the streams after PdfFileWriter's call to write()
close_streams(streams)
return result
return result_stream.getvalue()

@api.multi
def render_qweb_pdf(self, res_ids=None, data=None):
Expand Down

0 comments on commit 740d5ab

Please sign in to comment.