From 3642f1194244c66faa8dabb4be6abcfff789cda4 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 7 Dec 2016 11:41:18 +0100 Subject: [PATCH] [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 --- addons/report/i18n/report.pot | 12 +++++++++--- addons/report/models/report.py | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/report/i18n/report.pot b/addons/report/i18n/report.pot index a47f3d4e516..d1d4b22a840 100644 --- a/addons/report/i18n/report.pot +++ b/addons/report/i18n/report.pot @@ -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" 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 "" diff --git a/addons/report/models/report.py b/addons/report/models/report.py index 3a3f7ff2459..3e14f1dffca 100644 --- a/addons/report/models/report.py +++ b/addons/report/models/report.py @@ -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 = {}