Skip to content

odoo.tools.pdf selects legacy PyPDF2 3.x over pypdf, crashing multi-record PDF reports with DeprecationError #1346

Description

@gonzalesedwin1123

Cross-reference of odoo#281660 — the affected files are identical in OCB 19.0 (and 17.0/18.0).

Summary: setup.py declares an unpinned PyPDF2 while requirements.txt pins PyPDF==5.4.0 (modern pypdf) for python_version >= '3.13'. A pip/uv install of the OCB package on Python 3.13 therefore gets both pypdf 5.4.0 and legacy PyPDF2 3.0.1. odoo/tools/pdf/_pypdf2_2.py imports PyPDF2 with no version guard, so the legacy 3.x package wins the backend probe — and its removed camelCase API makes reader.numPages in ir_actions_report._render_qweb_pdf_prepare_streams raise PyPDF2.errors.DeprecationError whenever a qweb-pdf report is printed for more than one record. Single-record printing works, which hides the problem.

Suggested fixes (details and full traceback in the odoo/odoo issue):

  1. Version-guard _pypdf2_2.py (raise ImportError for PyPDF2 >= 3) so probing falls through to pypdf.
  2. Align setup.py's PyPDF2 requirement with requirements.txt.

Hit in production via OpenSPP's OCB 19.0 Docker image (python:3.13-slim); downstream workaround: OpenSPP/OpenSPP2#407 (install the odoo package with --no-deps, relying on requirements.txt for dependencies).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions