From 32b2718b3bbfc7aec37dd45f7c3f509fbaa5348b Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Mon, 2 Dec 2019 13:25:33 +0000 Subject: [PATCH] [FIX] base: Preserve loosing embedded files when printing 1 attachment With the reload from attachment ticked (attachment_use) when dealing with a single pdf, the attachment's content must be returned without calling _merge_pdfs in order to preserve the embedded files. Since PyPDF2 doesn't support completely the embedded files, there are simply dropped with creating a new pdf in _merge_pdfs even with a single attachement. closes odoo/odoo#41246 Issue: https://github.com/odoo/odoo/issues/41079 X-original-commit: a8f96bc7f35d047999cd16b7dd03bcddd3c32263 Signed-off-by: Laurent Smet --- odoo/addons/base/models/ir_actions_report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py index 94dee1a834a..708a939d170 100644 --- a/odoo/addons/base/models/ir_actions_report.py +++ b/odoo/addons/base/models/ir_actions_report.py @@ -559,8 +559,10 @@ class IrActionsReport(models.Model): pass # Check special case having only one record with existing attachment. + # In that case, return directly the attachment content. + # In that way, we also ensure the embedded files are well preserved. if len(save_in_attachment) == 1 and not pdf_content: - return self._merge_pdfs(list(save_in_attachment.values())) + return list(save_in_attachment.values())[0].getvalue() # Create a list of streams representing all sub-reports part of the final result # in order to append the existing attachments and the potentially modified sub-reports