From 27a232596c9fbb5553072cdf0dc10fdbf81b0106 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Thu, 27 Feb 2014 16:40:46 +0100 Subject: [PATCH] [IMP] Add notification on the web client when wkhtmltopdf is not present or too old bzr revid: sle@openerp.com-20140227154046-hxnhyho6v096hjx8 --- addons/report/controllers/main.py | 1 + addons/report/static/src/js/qwebactionmanager.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/report/controllers/main.py b/addons/report/controllers/main.py index fb0f4c40afd..f71d4ea7d8b 100644 --- a/addons/report/controllers/main.py +++ b/addons/report/controllers/main.py @@ -529,6 +529,7 @@ class Report(http.Controller): if LooseVersion(version) < LooseVersion('0.12.0'): _logger.warning('Upgrade WKHTMLTOPDF to (at least) 0.12.0') + return 'upgrade' return True except: diff --git a/addons/report/static/src/js/qwebactionmanager.js b/addons/report/static/src/js/qwebactionmanager.js index b2cc8313d7c..11c0a49f5b4 100644 --- a/addons/report/static/src/js/qwebactionmanager.js +++ b/addons/report/static/src/js/qwebactionmanager.js @@ -7,6 +7,7 @@ openerp.report = function(instance) { action = _.clone(action); var eval_contexts = ([instance.session.user_context] || []).concat([action.context]); action.context = instance.web.pyeval.eval('contexts',eval_contexts); + _t = instance.web._t; // QWeb reports if ('report_type' in action && (action.report_type == 'qweb-html' || action.report_type == 'qweb-pdf' || action.report_type == 'controller')) { @@ -48,7 +49,7 @@ openerp.report = function(instance) { } if (action.report_type == 'qweb-html') { // Open the html report in a popup - window.open(report_url); + window.open(report_url, '_blank', 'height=768,width=1024'); instance.web.unblockUI(); return; } else { @@ -61,10 +62,14 @@ openerp.report = function(instance) { openerp.session.rpc('/report/check_wkhtmltopdf').then(function (presence) { // Fallback of qweb-pdf if wkhtmltopdf is not installed if (!presence && action.report_type == 'qweb-pdf') { + self.do_notify(_t('Report'), _t('Unable to find Wkhtmltopdf on this system. The report will be shown in html.'), true); window.open(report_url.substring(12), '_blank', 'height=768,width=1024'); instance.web.unblockUI(); } else { + if (presence == 'upgrade') { + self.do_notify(_t('Report'), _t('You should upgrade your version of Wkhtmltopdf to at least 0.12.0 in order to get a correct display of headers and footers as well as support for table-breaking between pages.'), true); + } self.session.get_file({ url: '/report/download', data: {data: JSON.stringify(response)},