diff options
| author | Gery Debongnie <ged@openerp.com> | 2013-12-27 11:22:40 +0100 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2013-12-27 11:22:40 +0100 |
| commit | 0650d9d7380ec1885e6f9bd6627b7d14fd2eeded (patch) | |
| tree | 57e14ecd2998c24d0a715e3613419c0bb783280a /addons/web_graph/static/src/js | |
| parent | e1e676d737a2f682ed6a106e99b63a4dd377c5d5 (diff) | |
[FIX] correctly displays fields of type 'selection' in graph view. Previously, the code only displayed the key and not the value (addon web_graph)
bzr revid: ged@openerp.com-20131227102240-gmgik0p5lujssm3w
Diffstat (limited to 'addons/web_graph/static/src/js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 1 | ||||
| -rw-r--r-- | addons/web_graph/static/src/js/pivot.js | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 9806e7011a4..cfac0ea02f6 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -233,6 +233,7 @@ instance.web_graph.Graph = instance.web.Widget.extend({ // get the fields descriptions and measure list from the model var deferred2 = this.model.call('fields_get', []).then(function (fs) { self.fields = fs; + self.pivot.config({fields:fs}); var temp = _.map(fs, function (field, name) { return {name:name, type: field.type}; }); diff --git a/addons/web_graph/static/src/js/pivot.js b/addons/web_graph/static/src/js/pivot.js index a9a6a4f465e..e94b82df389 100644 --- a/addons/web_graph/static/src/js/pivot.js +++ b/addons/web_graph/static/src/js/pivot.js @@ -42,6 +42,10 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM }; options = _.extend(default_options, options); + if (options.fields) { + this.data_loader.fields = options.fields; + } + if (!_.isEqual(options.domain, this.domain)) { this.domain = options.domain; changed = true; @@ -302,6 +306,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM openerp.web_graph.DataLoader = openerp.web.Class.extend({ init: function (model) { this.model = model; + this.fields = null; }, get_groups: function (fields, domain, groupbys, options) { @@ -325,7 +330,7 @@ openerp.web_graph.DataLoader = openerp.web.Class.extend({ var non_empty_results = _.filter(results, function (group) { return group.attributes.length > 0; }); - _.each(non_empty_results, self.sanitize_value); + _.each(non_empty_results, self.sanitize_value.bind(self)); if (groupbys.length <= 1) { return non_empty_results; } else { @@ -345,6 +350,17 @@ openerp.web_graph.DataLoader = openerp.web.Class.extend({ sanitize_value: function (group) { var value = group.attributes.value; + + if (this.fields && + group.attributes.grouped_on && + this.fields[group.attributes.grouped_on].type === 'selection') { + var selection = this.fields[group.attributes.grouped_on].selection; + var value_lookup = _.find(selection, function (val) { + return val[0] === value; + }); + group.attributes.value = (value_lookup) ? value_lookup[1] : 'undefined'; + return; + } if (value === false) { group.attributes.value = 'undefined'; } else if (value instanceof Array) { |
