[IMP] web_graph: XLS export fail if more than 256 columns

When creating a XLS file with more than 256 columns, the library used
(xlwt) fail since it is targetted to support MS Excel 97 up to
Excel 2003.

But Odoo doesn't has no check and in this given instance (an error
happening in a controller generating a binary filte) the real error
message is lost.

This commit check if the to-be exported data has more than 256 columns,
and if this is the case display an error message without even trying
the export.

closes #10630

opw-660474
This commit is contained in:
Nicolas Lempereur 2016-01-26 15:40:42 +01:00
parent 014a1294b2
commit e95b01db3e
1 changed files with 6 additions and 1 deletions

View File

@ -850,10 +850,15 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
// ----------------------------------------------------------------------
export_xls: function() {
var c = openerp.webclient.crashmanager;
var table = this.build_table(true);
if(table.measure_row.length + 1 > 256) {
c.show_message(_t("For Excel compatibility, data cannot be exported if there is more than 256 columns.\n\nTip: try to flip axis, filter further or reduce the number of measures."))
return;
}
openerp.web.blockUI();
this.session.get_file({
url: '/web_graph/export_xls',
data: {data: JSON.stringify(this.build_table(true))},
data: {data: JSON.stringify(table)},
complete: openerp.web.unblockUI,
error: c.rpc_error.bind(c)
});