Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions brand_qweb_pdf_watermark/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
========================
Brand QWeb PDF Watermark
========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6438f9efa9332e9b70beac999d1a0f63146d0673ebed65d8cfdef1e7f963bfb5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbrand-lightgray.png?logo=github
:target: https://github.com/OCA/brand/tree/18.0/brand_qweb_pdf_watermark
:alt: OCA/brand
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/brand-18-0/brand-18-0-brand_qweb_pdf_watermark
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/brand&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to define a PDF or image watermark on each Brand,
which will be automatically applied to QWeb PDF reports printed for
documents belonging to that brand.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module:

1. Go to *Settings > Users & Companies > Brands*.
2. Open or create a brand.
3. In the *PDF Watermark* field, upload a PDF file.
4. When printing any QWeb PDF report for documents associated with this
brand, the watermark will be applied to the output PDF.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/brand/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/brand/issues/new?body=module:%20brand_qweb_pdf_watermark%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* CIT-Services

Contributors
------------

- `CIT-Services <https://cit-services.eu>`__

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/brand <https://github.com/OCA/brand/tree/18.0/brand_qweb_pdf_watermark>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions brand_qweb_pdf_watermark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions brand_qweb_pdf_watermark/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 CIT-Services
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Brand QWeb PDF Watermark",
"summary": "Add watermark to Brand reports",
"version": "18.0.1.0.0",
"category": "Technical",
"website": "https://github.com/OCA/brand",
"author": "CIT-Services, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"brand",
"report_qweb_pdf_watermark",
],
"data": [
"views/res_brand_views.xml",
],
"installable": True,
}
2 changes: 2 additions & 0 deletions brand_qweb_pdf_watermark/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_brand
from . import report
35 changes: 35 additions & 0 deletions brand_qweb_pdf_watermark/models/report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2026 CIT-Services
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import base64

from odoo import _, models
from odoo.exceptions import UserError


class Report(models.Model):
_inherit = "ir.actions.report"

def _get_watermark(self, report_ref, docids=False):
report_sudo = super()._get_report(report_ref)
if "brand_id" in self.env[report_sudo.model]._fields:
docs = self.env[report_sudo.model].browse(docids)
brands = docs.mapped("brand_id")
if len(brands) > 1:
brand_names = ", ".join(brands.mapped("name"))
raise UserError(
_(
"Cannot print documents belonging to "
"different brands (%s) together."
)
% brand_names
)
if brands and any(not doc.brand_id for doc in docs):
raise UserError(
_("Some of the documents do not have a brand linked to it.")
)
brand = docs and docs[0].brand_id
if brand and brand.pdf_watermark:
return base64.b64decode(brand.pdf_watermark)

return super()._get_watermark(report_ref, docids=docids)
13 changes: 13 additions & 0 deletions brand_qweb_pdf_watermark/models/res_brand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 CIT-Services
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResBrand(models.Model):
_inherit = "res.brand"

pdf_watermark = fields.Binary(
string="Watermark",
help="Upload a PDF or image file to use as a watermark for this brand.",
)
3 changes: 3 additions & 0 deletions brand_qweb_pdf_watermark/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions brand_qweb_pdf_watermark/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [CIT-Services](https://cit-services.eu)
3 changes: 3 additions & 0 deletions brand_qweb_pdf_watermark/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module allows you to define a PDF or image watermark on each Brand, which
will be automatically applied to QWeb PDF reports printed for documents
belonging to that brand.
7 changes: 7 additions & 0 deletions brand_qweb_pdf_watermark/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To use this module:

1. Go to *Settings > Users & Companies > Brands*.
2. Open or create a brand.
3. In the *PDF Watermark* field, upload a PDF file.
4. When printing any QWeb PDF report for documents associated with this brand,
the watermark will be applied to the output PDF.
Loading
Loading