[FIX] report: catch missing wkhtml error

If wkhtmltopdf is missing, a call to a report will be catched to warn the user.
In case of a report generated indirectly (e.g. via an attachment on an email
template), the rendering would crash.

As warning the user is better than returning a traceback, raise a UserError.

Closes #14535
This commit is contained in:
Martin Trigaux
2016-12-07 11:58:32 +01:00
parent 7ccf4e60c8
commit 3642f11942
2 changed files with 17 additions and 3 deletions
+9 -3
View File
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-09 11:58+0000\n"
"PO-Revision-Date: 2016-06-09 11:58+0000\n"
"POT-Creation-Date: 2016-12-07 10:39+0000\n"
"PO-Revision-Date: 2016-12-07 10:39+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -461,13 +461,19 @@ msgid "Unable to find Wkhtmltopdf on this \n"
"wkhtmltopdf.org</a>"
msgstr ""
#. module: report
#: code:addons/report/models/report.py:164
#, python-format
msgid "Unable to find Wkhtmltopdf on this system. The PDF can not be created."
msgstr ""
#. module: report
#: model:ir.ui.view,arch_db:report.external_layout_footer
msgid "Website:"
msgstr ""
#. module: report
#: code:addons/report/models/report.py:430
#: code:addons/report/models/report.py:464
#, python-format
msgid "Wkhtmltopdf failed (error code: %s). Message: %s"
msgstr ""
+8
View File
@@ -155,6 +155,14 @@ class Report(osv.Model):
def get_pdf(self, cr, uid, ids, report_name, html=None, data=None, context=None):
"""This method generates and returns pdf version of a report.
"""
if self._check_wkhtmltopdf() == 'install':
# wkhtmltopdf is not installed
# the call should be catched before (cf /report/check_wkhtmltopdf) but
# if get_pdf is called manually (email template), the check could be
# bypassed
raise UserError(_("Unable to find Wkhtmltopdf on this system. The PDF can not be created."))
if context is None:
context = {}