From dfe7bcecbf7cdf0fc957f8148e4a9bc647458c48 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 23 Feb 2023 15:19:17 +0000 Subject: [PATCH] [FIX] account: adapt pypdf2 import for both versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As PyPDF2 was bumped from 1.2.6 to 2.12.1 and made some breaking changes, we made an attempt in 8e0564dff to have Odoo working with both versions. This is necessary because of the imminent release of Debian Bookworm that will provide PyPDF 2.12.1. In the meanwhile this import broke the Bookworm nightly build. While at it, let's remove the unused `textwrap` import. closes odoo/odoo#113667 X-original-commit: 7431019b35ee71813ce8602f46ddc50a70c661ed Signed-off-by: Xavier Dollé (xdo) Signed-off-by: Christophe Monniez (moc) --- addons/account/models/ir_actions_report.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index 78d5ab3616f..19a949b6da8 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- -import textwrap from collections import OrderedDict -from PyPDF2.utils import PdfStreamError + +try: + from PyPDF2.errors import PdfStreamError +except ImportError: + from PyPDF2.utils import PdfStreamError from odoo import models, _ from odoo.exceptions import UserError