From bf6d58f165124ca773fcc220709ab70c89cb2b3a Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Thu, 9 Jun 2022 13:22:46 +0000 Subject: [PATCH] [FIX] base: Fix pdf generation with 'attachment_use' When generating a PDF report with an action having 'attachment_use' set and when the pdf of at least one record has been already generated but not all, an error is raised for no reason. X-original-commit: 7ad19283ea5c89a6629c8433b468d1dac3fdad4d Part-of: odoo/odoo#93516 --- odoo/addons/base/models/ir_actions_report.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py index d826f332dde..aafbe9ae402 100644 --- a/odoo/addons/base/models/ir_actions_report.py +++ b/odoo/addons/base/models/ir_actions_report.py @@ -688,7 +688,7 @@ class IrActionsReport(models.Model): bodies, html_ids, header, footer, specific_paperformat_args = self._prepare_html(html, report_model=self_sudo.model) - if self_sudo.attachment and set(res_ids) != set(html_ids): + if self_sudo.attachment and set(res_ids_wo_stream) != set(html_ids): raise UserError(_( "The report's template %r is wrong, please contact your administrator. \n\n" "Can not separate file to save as attachment because the report's template does not contains the" @@ -745,7 +745,7 @@ class IrActionsReport(models.Model): node = node['/Next'] outlines_pages = sorted(set(outlines_pages)) # There should be only one top-level heading by document - assert len(outlines_pages) == len(res_ids_wo_stream) + assert len(outlines_pages) == len(res_ids) # There should be a top-level heading on first page assert outlines_pages[0] == 0 for i, num in enumerate(outlines_pages): @@ -755,7 +755,7 @@ class IrActionsReport(models.Model): attachment_writer.addPage(reader.getPage(j)) stream = io.BytesIO() attachment_writer.write(stream) - collected_streams[res_ids_wo_stream[i]]['stream'] = stream + collected_streams[res_ids[i]]['stream'] = stream return collected_streams