From b8a5b2d2b509bd19ef580f6c137327dbbae924f5 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 11 Dec 2013 14:11:48 +0100 Subject: [IMP] takes all integer and float field from model as possible measure (addon web_graph) bzr revid: ged@openerp.com-20131211131148-vdfhmf96fn2txvcj --- addons/web_graph/static/src/js/graph.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'addons/web_graph/static/src/js/graph.js') diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 53f0308f24c..8070bb152ce 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -82,9 +82,9 @@ instance.web_graph.GraphView = instance.web.View.extend({ _.each(fields_view_get.arch.children, function (field) { if ('name' in field.attrs) { if ('operator' in field.attrs) { - self.measure_list.push(field.attrs.name); + measure = field.attrs.name; } else { - if (self.measure_list.length) { + if (measure) { self.default_col_groupby.push(field.attrs.name); } else { self.default_row_groupby.push(field.attrs.name); @@ -92,10 +92,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ } } }); - if (this.measure_list.length > 0) { - measure = this.measure_list[0]; - this.pivot_table.set_measure(measure); - } + this.pivot_table.set_measure(measure); // get the most important fields (of the model) by looking at the // groupby filters defined in the search view @@ -117,6 +114,16 @@ instance.web_graph.GraphView = instance.web.View.extend({ // get the fields descriptions from the model var deferred2 = this.model.call('fields_get', []).then(function (fs) { self.fields = fs; + var temp = _.map(fs, function (field, name) { + return {name:name, type: field.type}; + }); + temp = _.filter(temp, function (field) { + return (((field.type === 'integer') || (field.type === 'float')) && (field.name !== 'id')); + }); + self.measure_list = _.map(temp, function (field) { + return field.name; + }); + var measure_selection = self.$('.graph_measure_selection'); _.each(self.measure_list, function (measure) { var choice = $('').attr('data-choice', measure) -- cgit v1.2.3