Skip to content

[20.0][MIG] report_qweb_pdf_watermark: Migration to 20.0 - #1207

Open
BhaveshHeliconia wants to merge 35 commits into
OCA:20.0from
HeliconiaIO:20.0-mig-report_qweb_pdf_watermark
Open

BhaveshHeliconia wants to merge 35 commits into
OCA:20.0from
HeliconiaIO:20.0-mig-report_qweb_pdf_watermark

Conversation

@BhaveshHeliconia

Copy link
Copy Markdown

No description provided.

@OCA-git-bot OCA-git-bot added mod:report_qweb_pdf_watermark Module report_qweb_pdf_watermark series:20.0 labels Oct 5, 2026
@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot migration report_qweb_pdf_watermark

@OCA-git-bot OCA-git-bot added this to the 20.0 milestone Oct 5, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Oct 5, 2026
3 of 22 tasks
@BhaveshHeliconia
BhaveshHeliconia force-pushed the 20.0-mig-report_qweb_pdf_watermark branch from 3e1f73d to 2e1eb11 Compare October 5, 2026 10:48
@StefanRijnhart

Copy link
Copy Markdown
Member

Can you have a look at the tests?

@BhaveshHeliconia
BhaveshHeliconia force-pushed the 20.0-mig-report_qweb_pdf_watermark branch from 2e1eb11 to 385b012 Compare November 30, 2026 07:22
@oca-cla-bot

oca-cla-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@BhaveshHeliconia

Copy link
Copy Markdown
Author

Can you have a look at the tests?

The tests are green now. Thanks!

@StefanRijnhart StefanRijnhart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, when you did the migration, the 19.0 migration was not merged yet but it is now. Can you rebuild the branch on current 19.0?

>
Note that the watermark is not reflected in the preview to the right.
Print a report to see the watermark in the generated PDF.
</div>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another remark here would improve usability: the company background needs to be enabled per report before showing up at all.

name="pdf_watermark_setting"
string="PDF Watermark"
help="Use the company watermark or a specific one for this report"
invisible="report_type != 'qweb-pdf'"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You migrated the functionality to work with papermuncher reports, which is great! However, these have qweb-pdf-paper-muncher here so please adapt the condition to show the settings on those as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, one more, there is now also qweb-pdf-wkhtmltopdf.

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and upon retesting I can't get papermuncher to work on runbot so I'm wondering if I did it right the first time. Did you have any luck using papermuncher? Would be nice to round up support for it here.

  File "/mnt/data/odoo-addons-dir/report_qweb_pdf_watermark/models/report.py", line 180, in _render_qweb_pdf_prepare_streams
    collected_streams = super()._render_qweb_pdf_prepare_streams(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/odoo/addons/base/models/ir_actions_report.py", line 536, in _render_qweb_pdf_prepare_streams
    pdf_content, html_ids = self._run_pdf_engine(engine_name, html, report_ref=report_ref, landscape=self.env.context.get('landscape'))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/addons/base_report_paper_muncher/models/ir_actions_report.py", line 179, in _run_pdf_engine
    content = self._run_paper_muncher(
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/addons/base_report_paper_muncher/models/ir_actions_report.py", line 138, in _run_paper_muncher
    return server.serve(bodies, header, footer)  # TODO: ir.config_parameter
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/addons/base_report_paper_muncher/paper_muncher.py", line 137, in serve
    self._process_data()
  File "/opt/odoo/addons/base_report_paper_muncher/paper_muncher.py", line 162, in _process_data
    self._process_request()
  File "/opt/odoo/addons/base_report_paper_muncher/paper_muncher.py", line 179, in _process_request
    response, bytes_sent = self._handle_get((
                           ^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/addons/base_report_paper_muncher/paper_muncher.py", line 210, in _handle_get
    self._send(h11.Data(data=content))
  File "/opt/odoo/addons/base_report_paper_muncher/paper_muncher.py", line 342, in _send
    bytes_written += os.write(self._process.stdin.fileno(), memview[bytes_written:])
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BrokenPipeError: [Errno 32] Broken pipe
upon processing Request(method=b'GET', headers=<Headers([(b'user-agent', b'Mozilla/5.0 Paper-Muncher/v0.7.1'), (b'host', b'')])>, target=b'/paper-muncher/0.html', http_version=b'1.1')

sanderlienaerts and others added 17 commits November 30, 2026 15:40
When printing a document in a multi-company environment, the company
watermark was selected based on self.env.company (the company currently
active in the UI switcher) rather than the company of the document being
printed. This caused the wrong watermark to appear when a user switched
to company B and printed an invoice belonging to company A (or vice
versa), as reported in OCA#1134.

Fix by introducing a _get_watermark_company() helper that returns the
document's company_id when available, falling back to self.env.company
otherwise.
The module only tried to import PyPDF2, so on hosts that ship pypdf
(Odoo 19 on Python >= 3.13) PdfReader/PdfWriter stayed undefined and
rendering a watermarked report crashed with a NameError.

Import the PDF classes from odoo.tools.pdf instead, which picks PyPDF2
2.x, pypdf or PyPDF2 1.x and keeps the legacy method names used here.
Drop the obsolete INSTALL instructions to pip install PyPDF2.

Addresses OCA#1091 (review)

Co-authored-by: DjodyKort <90830682+DjodyKort@users.noreply.github.com>
…pany

Resolve the watermark company like core does: use the documents'
company_id, then company_ids, and fall back to the environment company.
Documents of models that only have company_ids now get their own
company's watermark, and the first document that carries a company is
used rather than only the first document.

Add tests for the company resolution.
Currently translated at 20.0% (2 of 10 strings)

Translation: reporting-engine-19.0/reporting-engine-19.0-report_qweb_pdf_watermark
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-19-0/reporting-engine-19-0-report_qweb_pdf_watermark/pl/
@BhaveshHeliconia
BhaveshHeliconia force-pushed the 20.0-mig-report_qweb_pdf_watermark branch from 385b012 to f25a641 Compare November 30, 2026 10:20
@BhaveshHeliconia

BhaveshHeliconia commented Nov 30, 2026 •

Copy link
Copy Markdown
Author

@StefanRijnhart Thanks for the review! I've rerun the migration process from 19.0 to 20.0 and addressed your comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:report_qweb_pdf_watermark Module report_qweb_pdf_watermark series:20.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.