Skip to content

[MIG] report_qweb_encrypt: Migration to 19.0 - #1188

Merged
OCA-git-bot merged 22 commits into
OCA:19.0from
vauxoo-dev:19.0-mig-report_qweb_encrypt
Aug 19, 2026
Merged

[MIG] report_qweb_encrypt: Migration to 19.0#1188
OCA-git-bot merged 22 commits into
OCA:19.0from
vauxoo-dev:19.0-mig-report_qweb_encrypt

Conversation

@moylop260

@moylop260 moylop260 commented Aug 14, 2026

Copy link
Copy Markdown

Import PdfReader/PdfWriter from odoo.tools.pdf instead of PyPDF2.
Odoo 19 pins PyPDF2==2.12.1 only up to python3.12;
from python 3.13 (Debian Trixie) it pins PyPDF==5.4.0,
where the legacy PdfFileReader/PdfFileWriter names no longer exist:

Going through odoo.tools.pdf keeps the module working on both backends,
since that wrapper already absorbs the difference for core.

appendPagesFromReader() is kept on purpose: it is the only spelling available on
every backend, the PyPDF2 1.x one does not provide append_pages_from_reader():

Replace self._context with self.env.context.
In 19.0 the _context property is decorated with @api.deprecated, so every access emits a
DeprecationWarning; it still returns self.env.context, but the indirection is scheduled for removal:

etobella and others added 20 commits August 14, 2026 19:45
Currently translated at 100.0% (11 of 11 strings)

Translation: reporting-engine-15.0/reporting-engine-15.0-report_qweb_encrypt
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-0-report_qweb_encrypt/es/
…m_name

reportname is not only a string but also a model or integer, the method
_get_report handles those cases to return the report.
Currently translated at 100.0% (11 of 11 strings)

Translation: reporting-engine-16.0/reporting-engine-16.0-report_qweb_encrypt
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-report_qweb_encrypt/it/
Changelog:

Controllers:
- Updated `report_download` parameters and reduce nested conditions.
- Decoded URL query parameters safely using
  `url_decode(url.split("?", 1)[1])`.

Models:
- Replaced `_()` by `self.env._()`.
- Removed unnecessary intermediate variables.
- Renamed variable `report` to `report_sudo` for clarity on sudoed
  record.

Views:
- Replaced `attrs` by individual `invisible` attributes.

Assets:
- Added `EncryptDialog` OWL component to prompt user for encryption
  password.
- Implemented `download_function` to handle password injection and PDF
  download.
- Refactored report URL building into `buildReportUrl` helper.
- Integrated `EncryptDialog` in `ir.actions.report handlers` registry
  under key `qweb-pdf-password`.
- Updated XML template `report_qweb_encrypt.EncryptDialogBody`: added
  password input field with `t-ref="password"`, added placeholder for
  better UX.
Currently translated at 100.0% (12 of 12 strings)

Translation: reporting-engine-18.0/reporting-engine-18.0-report_qweb_encrypt
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-report_qweb_encrypt/it/
@moylop260 moylop260 self-assigned this Aug 14, 2026
@OCA-git-bot OCA-git-bot added series:19.0 mod:report_qweb_encrypt Module report_qweb_encrypt labels Aug 14, 2026
@moylop260

Copy link
Copy Markdown
Author

/ocabot migration report_qweb_encrypt

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Aug 14, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Aug 14, 2026
21 tasks
Import PdfReader/PdfWriter from odoo.tools.pdf instead of PyPDF2.
Odoo 19 pins PyPDF2==2.12.1 only up to python3.12;
from python 3.13 (Debian Trixie) it pins PyPDF==5.4.0,
where the legacy PdfFileReader/PdfFileWriter names no longer exist:
 - https://github.com/odoo/odoo/blob/13e9e827dc21103052e8607d16f23c07adeb5634/odoo/tools/pdf/_pypdf.py#L1-L15

Going through odoo.tools.pdf keeps the module working on both backends,
since that wrapper already absorbs the difference for core.

appendPagesFromReader() is kept on purpose: it is the only spelling available on
every backend, the PyPDF2 1.x one does not provide append_pages_from_reader():
 - https://github.com/odoo/odoo/blob/13e9e827dc21103052e8607d16f23c07adeb5634/odoo/tools/pdf/_pypdf2_1.py#L28-L33

Replace self._context with self.env.context.
In 19.0 the _context property is decorated with @api.deprecated, so every access emits a
DeprecationWarning; it still returns self.env.context, but the indirection is scheduled for removal:
https://github.com/odoo/odoo/blob/13e9e827dc21103052e8607d16f23c07adeb5634/odoo/orm/models.py#L5921-L5924
@moylop260
moylop260 force-pushed the 19.0-mig-report_qweb_encrypt branch from a6bb5ce to 64c44de Compare August 14, 2026 21:21
controllers/main.py was at 25% coverage: no test reached report_download(),
so the manual-password branch was only exercised by hand. Core has no test
hitting /report/download either, so these cases are new.

The new class inherits odoo.addons.web.tests.test_reports.TestReports, so the
core report regression tests also run with this module installed.

force_report_rendering is required in the request context: while tests are
running _render_qweb_pdf() falls back to _render_qweb_html(), and an html
body cannot be encrypted, so without it the encryption branch is never
reached:
 - https://github.com/odoo/odoo/blob/13e9e827dc21103052e8607d16f23c07adeb5634/odoo/addons/base/models/ir_actions_report.py#L1027-L1028

Covered branches: password in the url context, url without query string,
context without password, and a non-pdf (qweb-text) response. This takes
controllers/main.py from 25.00% to 100.00%, and the module from 70.89% to
97.47%, which is back above the 80% fail-under.
@moylop260

Copy link
Copy Markdown
Author

@etobella @jarroyomorales @kittiu
WDY?

@moylop260

Copy link
Copy Markdown
Author

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 19.0-ocabot-merge-pr-1188-by-moylop260-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit b15336c into OCA:19.0 Aug 19, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at bfca132. Thanks a lot for contributing to OCA. ❤️

@moylop260
moylop260 deleted the 19.0-mig-report_qweb_encrypt branch August 24, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.