Skip to content
Merged
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ virtualenv:
install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- export WKHTMLTOPDF_VERSION=0.12.4

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is currently working on travis. The problem was related to wkhtmltopdf version. It must be 0.12.4, so I download it using travis_install_nightly.
Default Wkhtmltopdf version is not working because it does not add headers on the exported reports.

- travis_install_nightly

script:
Expand Down
3 changes: 2 additions & 1 deletion report_qweb_pdf_watermark/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
{
"name": "Pdf watermark",
"version": "10.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"author": "Therp BV, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Reporting",
"summary": "Add watermarks to your QWEB PDF reports",
Expand Down
7 changes: 7 additions & 0 deletions report_qweb_pdf_watermark/models/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
from PIL import Image
from StringIO import StringIO
from odoo import api, models, tools
from PIL import PdfImagePlugin # flake8: noqa

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment added on the code.
Codecov will fail because previous commits were failing.

# PdfImagePlugin must be loaded in order to work PNG to PDF transformation
# This issue is related to Pillow creation, as can be seen in its source code:
# https://github.com/python-pillow/Pillow/blob/master/PIL/PdfImagePlugin.py

logger = getLogger(__name__)


Expand Down Expand Up @@ -40,6 +46,7 @@ def get_pdf(self, docids, report_name, html=None, data=None):
except PdfReadError:
# let's see if we can convert this with pillow
try:
Image.init()
image = Image.open(StringIO(watermark))
pdf_buffer = StringIO()
if image.mode != 'RGB':
Expand Down