From e95b01db3ef0525f8213616fa32b586a1a178599 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 26 Jan 2016 15:40:42 +0100 Subject: [PATCH] [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 --- addons/web_graph/static/src/js/graph_widget.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index d936791d6a4..7ee972e095b 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -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) });