# HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1738157424 -3600 # Wed Jan 29 14:30:24 2025 +0100 # Branch 17.0 # Node ID c7a0de86f1d66d9e87dd7a1cc4878d799d6f50dd # Parent b6df8918dbbb7c753aa8a153684d08674704b24d Also remove python-magic from odoo manifest requirements diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -2,6 +2,11 @@ Changelog ========= +17.0.1.3.2 +---------- + +Also remove python-magic from odoo manifest requirements. + 17.0.1.3.1 ---------- diff --git a/__manifest__.py b/__manifest__.py --- a/__manifest__.py +++ b/__manifest__.py @@ -21,7 +21,7 @@ { "name": "Redner", "license": "AGPL-3", - "version": "17.0.1.3.1", + "version": "17.0.1.3.2", "category": "Reporting", "author": "XCG Consulting", "website": "https://orbeet.io/", @@ -43,5 +43,5 @@ ], }, "installable": True, - "external_dependencies": {"python": ["requests_unixsocket", "python-magic"]}, + "external_dependencies": {"python": ["requests_unixsocket"]}, } # HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1738157445 -3600 # Wed Jan 29 14:30:45 2025 +0100 # Branch 17.0 # Node ID 921a4e6a3c109d483eabe06197e26d954821c1f8 # Parent c7a0de86f1d66d9e87dd7a1cc4878d799d6f50dd 🔖 17.0.1.3.2 diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -33,3 +33,4 @@ 07224c0905af4f9c9c1d47d4acf369ce55c5c859 17.0.1.2.0 a6c94d540cb228b9dcf7dca24e53a35158b2c9ef 17.0.1.3.0 8989efa57c7fb5f0ed7560e043cab2930184fb69 17.0.1.3.1 +c7a0de86f1d66d9e87dd7a1cc4878d799d6f50dd 17.0.1.3.2 # HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1738156953 -3600 # Wed Jan 29 14:22:33 2025 +0100 # Branch 17.0 # Node ID 13065fe2a4d0c913f8f12ea15ff51bec52c94232 # Parent 921a4e6a3c109d483eabe06197e26d954821c1f8 ✨ Remove pypdf compatibility code to use Odoo pypdf compatibility instead. Requires a Odoo with [ADD] *: pypdf 3.x compatibility (https://github.com/odoo/odoo/commit/fddf53c9b6bcaea1a9ff7e041c0ccbb65a4647c8) diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -2,6 +2,12 @@ Changelog ========= +17.0.1.4.0 +---------- + +Remove pypdf compatibility code to use Odoo pypdf compatibility instead. +Requires a Odoo with `[ADD] *: pypdf 3.x compatibility <https://github.com/odoo/odoo/commit/fddf53c9b6bcaea1a9ff7e041c0ccbb65a4647c8>`_. + 17.0.1.3.2 ---------- diff --git a/__manifest__.py b/__manifest__.py --- a/__manifest__.py +++ b/__manifest__.py @@ -21,7 +21,7 @@ { "name": "Redner", "license": "AGPL-3", - "version": "17.0.1.3.2", + "version": "17.0.1.4.0", "category": "Reporting", "author": "XCG Consulting", "website": "https://orbeet.io/", diff --git a/models/redner_report.py b/models/redner_report.py --- a/models/redner_report.py +++ b/models/redner_report.py @@ -1,7 +1,7 @@ ############################################################################## # # Redner Odoo module -# Copyright © 2016, 2024 XCG Consulting <https://xcg-consulting.fr> +# Copyright © 2016, 2024, 2025 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -30,20 +30,13 @@ from odoo import _, api, fields, models # type: ignore[import-untyped] from odoo.exceptions import ValidationError # type: ignore[import-untyped] +from odoo.tools.pdf import PdfFileReader, PdfFileWriter # type: ignore[import-untyped] from ..utils import formats # type: ignore[import-untyped] from ..utils.formats import Formats # type: ignore[import-untyped] logger = logging.getLogger(__name__) -_pypdf2 = False -try: - from pypdf import PdfWriter -except ImportError: - from PyPDF2 import PdfFileReader, PdfFileWriter - - _pypdf2 = True - class RednerReport(models.TransientModel): _name = "redner.report" @@ -134,18 +127,18 @@ return result_path @api.model - def _merge_pdf(self, reports_path): + def _merge_pdf(self, reports_path: list[str]): """Merge PDF files into one. :param reports_path: list of path of pdf files :returns: path of the merged pdf """ - writer = PdfFileWriter() if _pypdf2 else PdfWriter() + # unlike odoo.tool.pdf.merge_pdf, does not store both files to merge and + # merged files in memory; only the merged file and a single file. + writer = PdfFileWriter() for path in reports_path: - if _pypdf2: - reader = PdfFileReader(path) + with open(path) as fd: + reader = PdfFileReader(fd, strict=False) writer.appendPagesFromReader(reader) - else: - writer.append(path) merged_file_fd, merged_file_path = tempfile.mkstemp( suffix=".pdf", prefix="report.merged.tmp." )