diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js
index 6c1f5ae3f32..78fb16582a9 100644
--- a/addons/web_graph/static/src/js/graph.js
+++ b/addons/web_graph/static/src/js/graph.js
@@ -193,13 +193,18 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.$('.graph_main_content svg').remove();
this.table.empty();
- var table_modes = ['pivot', 'heatmap', 'row_heatmap', 'col_heatmap'];
- if (_.contains(table_modes, this.mode)) {
- this.draw_table();
+ if (this.pivot_table.no_data) {
+ var msg = 'No data available. Try to remove any filter or add some data.';
+ this.table.append($('
| ' + msg + ' |
'));
} else {
- this.$('.graph_main_content').append($(''));
- var svg = this.$('.graph_main_content svg')[0];
- openerp.web_graph.draw_chart(this.mode, this.pivot_table, svg);
+ var table_modes = ['pivot', 'heatmap', 'row_heatmap', 'col_heatmap'];
+ if (_.contains(table_modes, this.mode)) {
+ this.draw_table();
+ } else {
+ this.$('.graph_main_content').append($(''));
+ var svg = this.$('.graph_main_content svg')[0];
+ openerp.web_graph.draw_chart(this.mode, this.pivot_table, svg);
+ }
}
},
diff --git a/addons/web_graph/static/src/js/pivot.js b/addons/web_graph/static/src/js/pivot.js
index 9171e1641f4..c7bf0ac492a 100644
--- a/addons/web_graph/static/src/js/pivot.js
+++ b/addons/web_graph/static/src/js/pivot.js
@@ -15,6 +15,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
this.measure_label = options.measure_label;
this.total = 0;
this.id_seed = 0;
+ this.no_data = true;
},
start: function () {
@@ -151,22 +152,27 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
var self = this;
return this.query_all_values().then(function (result) {
- self.rows.headers = result.row_headers;
- self.cols.headers = result.col_headers;
- self.cells = result.cells;
- self.rows.main = self.rows.headers[0];
- self.cols.main = self.cols.headers[0];
- self.total = self.rows.main.total;
- self.rows.main.title = 'Total';
- self.cols.main.title = self.measure_label;
- _.each(self.rows.headers, function (row) {
- row.root = self.rows;
- row.is_expanded = (row.children.length > 0);
- });
- _.each(self.cols.headers, function (col) {
- col.root = self.cols;
- col.is_expanded = (col.children.length > 0);
- });
+ if (result) {
+ self.no_data = false;
+ self.rows.headers = result.row_headers;
+ self.cols.headers = result.col_headers;
+ self.cells = result.cells;
+ self.rows.main = self.rows.headers[0];
+ self.cols.main = self.cols.headers[0];
+ self.total = self.rows.main.total;
+ self.rows.main.title = 'Total';
+ self.cols.main.title = self.measure_label;
+ _.each(self.rows.headers, function (row) {
+ row.root = self.rows;
+ row.is_expanded = (row.children.length > 0);
+ });
+ _.each(self.cols.headers, function (col) {
+ col.root = self.cols;
+ col.is_expanded = (col.children.length > 0);
+ });
+ } else {
+ self.no_data = true;
+ }
});
},
@@ -174,6 +180,10 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
update_values: function () {
var self = this;
return this.query_all_values().then(function (result) {
+ if (!result) {
+ return undefined;
+ }
+ self.no_data = false;
var old_col_headers = self.cols.headers,
old_row_headers = self.rows.headers;
@@ -291,7 +301,10 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
row_data = _.last(_.initial(args)),
cell_data = args;
- return self.format_data(total, col_data, row_data, cell_data);
+ if (total === undefined) { self.no_data = true;}
+ return (total === undefined)
+ ? undefined
+ : self.format_data(total, col_data, row_data, cell_data);
});
},