Skip to content

Commit

Permalink
Merge commit 'refs/pull/605/head' of github.com:OCA/l10n-switzerland …
Browse files Browse the repository at this point in the history
…into merge-branch-2270-master-bc2c4240
  • Loading branch information
vrenaville committed Dec 7, 2021
2 parents 648d933 + 076d945 commit 9aa890a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions l10n_ch_invoice_reports/models/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,26 @@ def render_qweb_pdf(self, res_ids=None, data=None):
]
if self.report_name not in reports or not res_ids:
return super().render_qweb_pdf(res_ids, data)
inv_report = self._get_report_from_name("account.report_invoice")
invoice_pdf, _ = inv_report.render_qweb_pdf(res_ids, data)
invoice_pdf_io = io.BytesIO(invoice_pdf)
tmp_stream_io = []
for res_id in res_ids:
inv_report = self._get_report_from_name("account.report_invoice")
invoice_pdf, _ = inv_report.render_qweb_pdf(res_id, data)
invoice_pdf_io = io.BytesIO(invoice_pdf)

isr_report = self._get_report_from_name("l10n_ch.isr_report_main")
isr_pdf, _ = isr_report.render_qweb_pdf(res_ids, data)
isr_pdf_io = io.BytesIO(isr_pdf)
isr_report = self._get_report_from_name("l10n_ch.isr_report_main")
isr_pdf, _ = isr_report.render_qweb_pdf(res_id, data)
isr_pdf_io = io.BytesIO(isr_pdf)

qr_report = self._get_report_from_name("l10n_ch.qr_report_main")
qr_pdf, _ = qr_report.render_qweb_pdf(res_ids, data)
qr_pdf_io = io.BytesIO(qr_pdf)

pdf = False
if self.report_name == reports[0]:
pdf = self.merge_pdf_in_memory([invoice_pdf_io, isr_pdf_io])
elif self.report_name == reports[1]:
pdf = self.merge_pdf_in_memory([invoice_pdf_io, qr_pdf_io])
else:
pdf = self.merge_pdf_in_memory([invoice_pdf_io, isr_pdf_io, qr_pdf_io])
invoice_pdf_io.close()
isr_pdf_io.close()
qr_pdf_io.close()
qr_report = self._get_report_from_name("l10n_ch.qr_report_main")
qr_pdf, _ = qr_report.render_qweb_pdf(res_id, data)
qr_pdf_io = io.BytesIO(qr_pdf)
if self.report_name == reports[0]:
tmp_stream_io += [invoice_pdf_io, isr_pdf_io]
elif self.report_name == reports[1]:
tmp_stream_io += [invoice_pdf_io, qr_pdf_io]
else:
tmp_stream_io += [invoice_pdf_io, isr_pdf_io, qr_pdf_io]
pdf = self.merge_pdf_in_memory(tmp_stream_io)
for stream in tmp_stream_io:
stream.close()
return (pdf, "pdf")

0 comments on commit 9aa890a

Please sign in to comment.