From b83cfc2c2b900f33d08ba068ab7b4d468ddb3017 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 23 Jan 2014 12:34:50 +0100 Subject: [PATCH] [FIX] fixes a crash happening when in dashboards, the graph view was trying to access undefined attributes (addon web_graph) bzr revid: ged@openerp.com-20140123113450-ec4fubf1urkdutw7 --- addons/web_graph/static/src/js/graph_view.js | 2 +- addons/web_graph/static/src/js/graph_widget.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/web_graph/static/src/js/graph_view.js b/addons/web_graph/static/src/js/graph_view.js index 6d121bdc6c5..39634ff103a 100644 --- a/addons/web_graph/static/src/js/graph_view.js +++ b/addons/web_graph/static/src/js/graph_view.js @@ -173,7 +173,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ context[category] = groupby.field; var value; if (category === 'group_by' && groupby.type !== 'date' && groupby.type !== 'datetime') { - value = groupby.filter; + value = groupby.filter || {attrs: {domain: [], context: context}}; } else { value = {attrs: {domain: [], context: context}}; } diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 346e8c3b808..64b163e883d 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -43,6 +43,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return this.model.call('fields_get', []).then(function (f) { self.fields = f; + self.fields.__count = {field:'__count', type: 'integer', string:'Quantity'}; self.measure_list = self.get_measures(); self.add_measures_to_options(); self.pivot_options.row_groupby = self.create_field_values(self.pivot_options.row_groupby || []); @@ -87,7 +88,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Extracts the integer/float fields which are not 'id' get_measures: function() { - var measures = [{field:'__count', type: 'integer', string:'Quantity'}]; + var measures = []; _.each(this.fields, function (f, id) { if (((f.type === 'integer') || (f.type === 'float')) && (id !== 'id')) { measures.push({field:id, type: f.type, string: f.string});