[FIX] report: correctly handle broken wkhtmltopdf
It's possible that the command `wkhtmltopdf --version` returns an empty string (in the use case, it output later in stdout "wkhtmltopdf: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory"). We chose to display the report in html in this case and also to show a warning to the user inviting him to fix his installation.
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 9.0\n"
|
||||
"Project-Id-Version: Odoo Server 9.0c\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-09-29 10:26+0000\n"
|
||||
"PO-Revision-Date: 2015-09-29 10:26+0000\n"
|
||||
"POT-Creation-Date: 2016-06-09 11:58+0000\n"
|
||||
"PO-Revision-Date: 2016-06-09 11:58+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -21,7 +21,6 @@ msgid "&bull;"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: model:ir.ui.view,arch_db:report.layout
|
||||
#: model:ir.ui.view,arch_db:report.minimal_layout
|
||||
msgid "<!DOCTYPE html>"
|
||||
msgstr ""
|
||||
@@ -142,7 +141,7 @@ msgid "B9 23 33 x 62 mm"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: code:addons/report/models/report.py:257
|
||||
#: code:addons/report/models/report.py:274
|
||||
#, python-format
|
||||
msgid "Bad Report Reference"
|
||||
msgstr ""
|
||||
@@ -195,6 +194,7 @@ msgid "Default paper format ?"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: model:ir.model.fields,field_description:report.field_ir_qweb_field_barcode_display_name
|
||||
#: model:ir.model.fields,field_description:report.field_report_abstract_report_display_name
|
||||
#: model:ir.model.fields,field_description:report.field_report_display_name
|
||||
#: model:ir.model.fields,field_description:report.field_report_paperformat_display_name
|
||||
@@ -257,6 +257,7 @@ msgid "Header spacing"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: model:ir.model.fields,field_description:report.field_ir_qweb_field_barcode_id
|
||||
#: model:ir.model.fields,field_description:report.field_report_abstract_report_id
|
||||
#: model:ir.model.fields,field_description:report.field_report_id
|
||||
#: model:ir.model.fields,field_description:report.field_report_paperformat_id
|
||||
@@ -269,6 +270,7 @@ msgid "Landscape"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: model:ir.model.fields,field_description:report.field_ir_qweb_field_barcode___last_update
|
||||
#: model:ir.model.fields,field_description:report.field_report___last_update
|
||||
#: model:ir.model.fields,field_description:report.field_report_abstract_report___last_update
|
||||
#: model:ir.model.fields,field_description:report.field_report_paperformat___last_update
|
||||
@@ -391,6 +393,7 @@ msgstr ""
|
||||
#: code:addons/report/static/src/js/qwebactionmanager.js:76
|
||||
#: code:addons/report/static/src/js/qwebactionmanager.js:84
|
||||
#: code:addons/report/static/src/js/qwebactionmanager.js:91
|
||||
#: code:addons/report/static/src/js/qwebactionmanager.js:96
|
||||
#: model:ir.model,name:report.model_report
|
||||
#, python-format
|
||||
msgid "Report"
|
||||
@@ -439,7 +442,7 @@ msgid "This is a sample of an internal report."
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: code:addons/report/models/report.py:257
|
||||
#: code:addons/report/models/report.py:274
|
||||
#, python-format
|
||||
msgid "This report is not loaded into the database: %s."
|
||||
msgstr ""
|
||||
@@ -464,7 +467,7 @@ msgid "Website:"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: code:addons/report/models/report.py:413
|
||||
#: code:addons/report/models/report.py:430
|
||||
#, python-format
|
||||
msgid "Wkhtmltopdf failed (error code: %s). Message: %s"
|
||||
msgstr ""
|
||||
@@ -488,12 +491,9 @@ msgid "You should upgrade your version of\n"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: model:ir.model,name:report.model_ir_actions_report_xml
|
||||
msgid "ir.actions.report.xml"
|
||||
#. openerp-web
|
||||
#: code:addons/report/static/src/js/qwebactionmanager.js:96
|
||||
#, python-format
|
||||
msgid "Your installation of Wkhtmltopdf seems to be broken. The \n"
|
||||
"report will be shown in html.<br><br><a href=\"http://wkhtmltopdf.org/\" target=\"_blank\">wkhtmltopdf.org</a>"
|
||||
msgstr ""
|
||||
|
||||
#. module: report
|
||||
#: model:ir.model,name:report.model_report_abstract_report
|
||||
msgid "report.abstract_report"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -61,16 +61,21 @@ except (OSError, IOError):
|
||||
else:
|
||||
_logger.info('Will use the Wkhtmltopdf binary at %s' % _get_wkhtmltopdf_bin())
|
||||
out, err = process.communicate()
|
||||
version = re.search('([0-9.]+)', out or "0").group(0)
|
||||
if LooseVersion(version) < LooseVersion('0.12.0'):
|
||||
_logger.info('Upgrade Wkhtmltopdf to (at least) 0.12.0')
|
||||
wkhtmltopdf_state = 'upgrade'
|
||||
else:
|
||||
wkhtmltopdf_state = 'ok'
|
||||
match = re.search('([0-9.]+)', out)
|
||||
if match:
|
||||
version = match.group(0)
|
||||
if LooseVersion(version) < LooseVersion('0.12.0'):
|
||||
_logger.info('Upgrade Wkhtmltopdf to (at least) 0.12.0')
|
||||
wkhtmltopdf_state = 'upgrade'
|
||||
else:
|
||||
wkhtmltopdf_state = 'ok'
|
||||
|
||||
if config['workers'] == 1:
|
||||
_logger.info('You need to start Odoo with at least two workers to print a pdf version of the reports.')
|
||||
wkhtmltopdf_state = 'workers'
|
||||
if config['workers'] == 1:
|
||||
_logger.info('You need to start Odoo with at least two workers to print a pdf version of the reports.')
|
||||
wkhtmltopdf_state = 'workers'
|
||||
else:
|
||||
_logger.info('Wkhtmltopdf seems to be broken.')
|
||||
wkhtmltopdf_state = 'broken'
|
||||
|
||||
|
||||
class Report(osv.Model):
|
||||
|
||||
@@ -92,6 +92,13 @@ workers to print a pdf version of the reports.'), true);
|
||||
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.<br><br><a href="http://wkhtmltopdf.org/" \
|
||||
target="_blank">wkhtmltopdf.org</a>'), true);
|
||||
} else if (presence === 'broken') {
|
||||
self.do_notify(_t('Report'), _t('Your installation of Wkhtmltopdf seems to be broken. The \
|
||||
report will be shown in html.<br><br><a href="http://wkhtmltopdf.org/" target="_blank">wkhtmltopdf.org</a>'), true);
|
||||
report_url = report_url.substring(12);
|
||||
window.open('/report/html/' + report_url, '_blank', 'height=768,width=1024');
|
||||
framework.unblockUI();
|
||||
return;
|
||||
}
|
||||
return trigger_download(self.session, response, c, action, options);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user