Skip to content

[FIX] Fix Watermark from PNG - #144

Merged
pedrobaeza merged 2 commits into
OCA:10.0from
etobella:10.0-fix_watermark_png
Jun 23, 2017
Merged

pedrobaeza merged 2 commits into
OCA:10.0from
etobella:10.0-fix_watermark_png

Conversation

@etobella

Copy link
Copy Markdown
Member

When we are trying to create a Watermark from a PNG, we need to import PdfImagePlugin.

"name": "Pdf watermark",
"version": "10.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"version": "10.0.2.0.0",

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.

This is a fix, not a new refactoring, so please change only last number. Check https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md#version-numbers

except PdfReadError:
# let's see if we can convert this with pillow
try:
from PIL import PdfImagePlugin

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.

Where is this import used?

@etobella
etobella force-pushed the 10.0-fix_watermark_png branch 3 times, most recently from 75b8e2a to ec30d60 Compare June 20, 2017 09:50
@etobella

Copy link
Copy Markdown
Member Author

If PdfImagePlugin is not initialized, we cannot transform a PNG image to PDF. The problem is related to Pillow creation: https://github.com/python-pillow/Pillow/blob/master/PIL/PdfImagePlugin.py

@pedrobaeza

Copy link
Copy Markdown
Member

Please add this explanation as comment before the import line so that others that see the code don't wonder the same.

@JordiBForgeFlow

Copy link
Copy Markdown
Member

@alexis-via We need your help to test the generation of reports in PDF. Currently we are getting stuck when the wkhtmltopdf process is run, and a subprocess is open:
https://github.com/odoo/odoo/blob/10.0/addons/report/models/report.py#L445

However it seems that you managed to get past this issue here!:
https://github.com/akretion/edi/blob/10-migrate/account_invoice_factur-x/tests/test_facturx_invoice.py#L16

@etobella
etobella force-pushed the 10.0-fix_watermark_png branch 2 times, most recently from 0c22939 to 6daceca Compare June 21, 2017 08:24
Comment thread .travis.yml
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.

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.

@JordiBForgeFlow JordiBForgeFlow 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.

Tested on runbot. Allows to print from a watermark using a PNG image

@pedrobaeza pedrobaeza 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.

This will mean a problem with my other PR (https://github.com/OCA/reporting-engine/pull/145/files#diff-354f30a63fb0907d4ad57269548329e3R9), but when the first will be merged, then we solve the conflicts

@pedrobaeza

Copy link
Copy Markdown
Member

Fast-tracking this for leading with the other PR

@pedrobaeza
pedrobaeza merged commit 074f3a2 into OCA:10.0 Jun 23, 2017
@etobella
etobella deleted the 10.0-fix_watermark_png branch June 23, 2017 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants