From f0e0e2ea38b23849234bc2d03e4914cd976f1208 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Fri, 16 Jun 2023 10:25:36 +0000 Subject: [PATCH] [FIX] account: skip banner on faulty PDF create a vendor Bill attach the PDF go back to list view, select the bill > print Original Bills Issue: a traceback is raised Similar to f814c607e5ab7ed6f1e594ec8c602a749fcc775d In some malformed PDF files zlib is unable to extract the data properly. opw-3368907 closes odoo/odoo#125501 X-original-commit: 6dd9fee03a50310a4db63e3f263eb43ab808dbc7 Signed-off-by: John Laterre (jol) Signed-off-by: Grazioso Andrea (agr) --- addons/account/models/ir_actions_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index 8cf5b086615..40b5b45a7e2 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from collections import OrderedDict - +from zlib import error as zlib_error try: from PyPDF2.errors import PdfStreamError, PdfReadError except ImportError: @@ -36,7 +36,7 @@ class IrActionsReport(models.Model): record = self.env[attachment.res_model].browse(attachment.res_id) try: stream = pdf.add_banner(stream, record.name, logo=True) - except (ValueError, PdfStreamError, PdfReadError, TypeError): + except (ValueError, PdfStreamError, PdfReadError, TypeError, zlib_error): record._message_log(body=_( "There was an error when trying to add the banner to the original PDF.\n" "Please make sure the source file is valid."