Skip to content

Commit 210c266

Browse files
[IMP] Add _get_pdf_watermark function to be able to inherit and select a pdf from another model.
1 parent 3bd8709 commit 210c266

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

report_qweb_pdf_watermark/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Contributors
132132
* Foram Shah <[email protected]>
133133
* Emiel van Bokhoven <[email protected]>
134134
* Anjeel Haria
135+
* Hugo Martínez <[email protected]>
135136

136137
Maintainers
137138
~~~~~~~~~~~

report_qweb_pdf_watermark/models/report.py

+25-21
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,7 @@ def pdf_has_usable_pages(self, numpages):
6262
)
6363
return True
6464

65-
@api.model
66-
def _run_wkhtmltopdf(
67-
self,
68-
bodies,
69-
report_ref=False,
70-
header=None,
71-
footer=None,
72-
landscape=False,
73-
specific_paperformat_args=None,
74-
set_viewport_size=False,
75-
):
76-
result = super(Report, self)._run_wkhtmltopdf(
77-
bodies,
78-
report_ref=report_ref,
79-
header=header,
80-
footer=footer,
81-
landscape=landscape,
82-
specific_paperformat_args=specific_paperformat_args,
83-
set_viewport_size=set_viewport_size,
84-
)
85-
65+
def _get_watermark(self, report_ref):
8666
docids = self.env.context.get("res_ids", False)
8767
report_sudo = self._get_report(report_ref)
8868
watermark = None
@@ -105,6 +85,30 @@ def _run_wkhtmltopdf(
10585
if watermark:
10686
watermark = b64decode(watermark)
10787

88+
return watermark
89+
90+
@api.model
91+
def _run_wkhtmltopdf(
92+
self,
93+
bodies,
94+
report_ref=False,
95+
header=None,
96+
footer=None,
97+
landscape=False,
98+
specific_paperformat_args=None,
99+
set_viewport_size=False,
100+
):
101+
result = super(Report, self)._run_wkhtmltopdf(
102+
bodies,
103+
report_ref=report_ref,
104+
header=header,
105+
footer=footer,
106+
landscape=landscape,
107+
specific_paperformat_args=specific_paperformat_args,
108+
set_viewport_size=set_viewport_size,
109+
)
110+
watermark = self._get_watermark(report_ref)
111+
108112
if not watermark:
109113
return result
110114

report_qweb_pdf_watermark/readme/CONTRIBUTORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
* Foram Shah <[email protected]>
66
* Emiel van Bokhoven <[email protected]>
77
* Anjeel Haria
8+
* Hugo Martínez <[email protected]>

report_qweb_pdf_watermark/static/description/index.html

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
@@ -9,10 +8,11 @@
98

109
/*
1110
:Author: David Goodger ([email protected])
12-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1616
1717
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1818
customize this style sheet.
@@ -275,7 +275,7 @@
275275
margin-left: 2em ;
276276
margin-right: 2em }
277277

278-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
279279
pre.code, code { background-color: #eeeeee }
280280
pre.code .comment, code .comment { color: #5C6576 }
281281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@
301301
span.pre {
302302
white-space: pre }
303303

304-
span.problematic {
304+
span.problematic, pre.problematic {
305305
color: red }
306306

307307
span.section-subtitle {
@@ -489,12 +489,15 @@ <h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
489489
<li>Foram Shah &lt;<a class="reference external" href="mailto:foram.shah&#64;initos.com">foram.shah&#64;initos.com</a>&gt;</li>
490490
<li>Emiel van Bokhoven &lt;<a class="reference external" href="mailto:emiel&#64;360erp.nl">emiel&#64;360erp.nl</a>&gt;</li>
491491
<li>Anjeel Haria</li>
492+
<li>Hugo Martínez &lt;<a class="reference external" href="mailto:hugo.martinez&#64;netkia.es">hugo.martinez&#64;netkia.es</a>&gt;</li>
492493
</ul>
493494
</div>
494495
<div class="section" id="maintainers">
495496
<h2><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h2>
496497
<p>This module is maintained by the OCA.</p>
497-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
498+
<a class="reference external image-reference" href="https://odoo-community.org">
499+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
500+
</a>
498501
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
499502
mission is to support the collaborative development of Odoo features and
500503
promote its widespread use.</p>

0 commit comments

Comments
 (0)