2014-02-18 10:49:59 +00:00
|
|
|
openerp.report = function(instance) {
|
2014-03-21 16:47:16 +00:00
|
|
|
var wkhtmltopdf_state;
|
2014-02-18 10:49:59 +00:00
|
|
|
|
2014-04-04 12:47:24 +00:00
|
|
|
var trigger_download = function(session, response, c) {
|
|
|
|
session.get_file({
|
|
|
|
url: '/report/download',
|
|
|
|
data: {data: JSON.stringify(response)},
|
|
|
|
complete: openerp.web.unblockUI,
|
|
|
|
error: c.rpc_error.bind(c)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:49:59 +00:00
|
|
|
instance.web.ActionManager = instance.web.ActionManager.extend({
|
|
|
|
ir_actions_report_xml: function(action, options) {
|
|
|
|
var self = this;
|
|
|
|
instance.web.blockUI();
|
|
|
|
action = _.clone(action);
|
2014-02-27 15:40:46 +00:00
|
|
|
_t = instance.web._t;
|
2014-02-18 10:49:59 +00:00
|
|
|
|
|
|
|
// QWeb reports
|
2014-02-21 16:33:20 +00:00
|
|
|
if ('report_type' in action && (action.report_type == 'qweb-html' || action.report_type == 'qweb-pdf' || action.report_type == 'controller')) {
|
2014-03-21 16:47:16 +00:00
|
|
|
var report_url = '';
|
2014-02-21 16:33:20 +00:00
|
|
|
switch (action.report_type) {
|
|
|
|
case 'qweb-html':
|
2014-04-02 16:23:44 +00:00
|
|
|
report_url = '/report/html/' + action.report_name;
|
2014-02-21 16:33:20 +00:00
|
|
|
break;
|
|
|
|
case 'qweb-pdf':
|
2014-04-02 16:23:44 +00:00
|
|
|
report_url = '/report/pdf/' + action.report_name;
|
2014-02-21 16:33:20 +00:00
|
|
|
break;
|
|
|
|
case 'controller':
|
|
|
|
report_url = action.report_file;
|
|
|
|
break;
|
|
|
|
default:
|
2014-04-02 16:23:44 +00:00
|
|
|
report_url = '/report/html/' + action.report_name;
|
2014-02-21 16:33:20 +00:00
|
|
|
break;
|
2014-02-18 10:49:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 16:23:44 +00:00
|
|
|
// generic report: no query string
|
|
|
|
// particular: query string of action.data.form and context
|
|
|
|
if (!('data' in action) || !(action.data)) {
|
2014-02-18 10:49:59 +00:00
|
|
|
if ('active_ids' in action.context) {
|
|
|
|
report_url += "/" + action.context.active_ids.join(',');
|
|
|
|
}
|
|
|
|
} else {
|
2014-04-03 21:17:17 +00:00
|
|
|
report_url += "?options=" + encodeURIComponent(JSON.stringify(action.data));
|
|
|
|
report_url += "&context=" + encodeURIComponent(JSON.stringify(action.context));
|
2014-02-18 10:49:59 +00:00
|
|
|
}
|
2014-04-02 16:23:44 +00:00
|
|
|
|
2014-04-04 12:47:24 +00:00
|
|
|
var response = new Array();
|
|
|
|
response[0] = report_url;
|
|
|
|
response[1] = action.report_type;
|
|
|
|
var c = openerp.webclient.crashmanager;
|
|
|
|
|
2014-03-21 18:36:49 +00:00
|
|
|
if (action.report_type == 'qweb-html') {
|
2014-03-21 10:58:06 +00:00
|
|
|
window.open(report_url, '_blank', 'height=900,width=1280');
|
2014-02-18 12:53:22 +00:00
|
|
|
instance.web.unblockUI();
|
|
|
|
} else {
|
2014-03-21 18:36:49 +00:00
|
|
|
// Trigger the download of the pdf/controller report
|
2014-02-21 16:33:20 +00:00
|
|
|
|
2014-03-21 18:36:49 +00:00
|
|
|
if (action.report_type == 'qweb-pdf') {
|
|
|
|
(wkhtmltopdf_state = wkhtmltopdf_state || openerp.session.rpc('/report/check_wkhtmltopdf')).then(function (presence) {
|
|
|
|
// Fallback of qweb-pdf if wkhtmltopdf is not installed
|
|
|
|
if (presence == 'install' && 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.<br><br><a href="http://wkhtmltopdf.org/" target="_blank">\
|
|
|
|
wkhtmltopdf.org</a>'), true);
|
2014-04-04 12:47:24 +00:00
|
|
|
report_url = report_url.substring(12)
|
|
|
|
window.open('/report/html/' + report_url, '_blank', 'height=768,width=1024');
|
2014-03-21 18:36:49 +00:00
|
|
|
instance.web.unblockUI();
|
2014-04-02 16:23:44 +00:00
|
|
|
return;
|
2014-03-21 18:36:49 +00:00
|
|
|
} 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.<br><br><a href="http://wkhtmltopdf.org/" \
|
|
|
|
target="_blank">wkhtmltopdf.org</a>'), true);
|
|
|
|
}
|
2014-02-27 15:40:46 +00:00
|
|
|
}
|
2014-04-04 12:47:24 +00:00
|
|
|
return trigger_download(self.session, response, c);
|
2014-03-21 18:36:49 +00:00
|
|
|
});
|
[REM] removed details_summary, sales_user, sales_user_today, payment_user reports, wizards and rml
[REM] dead code: pos_box_entries.py/xml, pos_box_out.py/xml, pos_return_view.py/xml
[ADD] lines, invoice, cashbox of the day, payment, receipt, users product reports converted to QWeb. Added YML tests for the bank statement reports.
[FIX] closed cashbox of the day sql using old fields in its queries, yml test not correctly generating an invoice from a pos order
bzr revid: sle@openerp.com-20140414104954-xj10wi640tyr3ufe
2014-04-14 10:49:54 +00:00
|
|
|
} else if (action.report_type == 'controller') {
|
2014-04-04 12:47:24 +00:00
|
|
|
return trigger_download(self.session, response, c);
|
|
|
|
}
|
2014-03-21 18:36:49 +00:00
|
|
|
}
|
2014-02-18 10:49:59 +00:00
|
|
|
} else {
|
|
|
|
return self._super(action, options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|