diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-06-01 10:26:50 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-06-01 12:02:17 +0200 |
| commit | 2f4d3d0e667092f70f44db03437473acf4ad5b32 (patch) | |
| tree | c2391824366cbbcbf75d4de7fbed27ba9bfb88d3 /addons/web/static/src/js/views/graph/graph_model.js | |
| parent | 033aec082669d6fb8126d6740b8aa7d09a2831d3 (diff) | |
[FIX] web: Graph: don't ignore graph keys in context
Keys 'graph_mode', 'graph_measure' and 'graph_groupbys' can be
specified in the context and must be used by the graph view to
determine the default mode, meadure and groupbys. Before this rev.,
those keys were simply ignored.
Diffstat (limited to 'addons/web/static/src/js/views/graph/graph_model.js')
| -rw-r--r-- | addons/web/static/src/js/views/graph/graph_model.js | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_model.js b/addons/web/static/src/js/views/graph/graph_model.js index 877472a7bc2..5948e07a54f 100644 --- a/addons/web/static/src/js/views/graph/graph_model.js +++ b/addons/web/static/src/js/views/graph/graph_model.js @@ -46,30 +46,23 @@ return AbstractModel.extend({ * should be done by the graphView I think. * * @param {Object} params - * @param {string[]} params.groupedBy - * @param {string} params.initialMode one of 'pie', 'bar', 'line - * @param {string} params.initialMeasure a valid field name - * @param {string[]} params.initialGroupBys a list of valid field names + * @param {string} params.mode one of 'pie', 'bar', 'line + * @param {string} params.measure a valid field name + * @param {string[]} params.groupBys a list of valid field names * @param {Object} params.context * @param {string[]} params.domain * @returns {Deferred} The deferred does not return a handle, we don't need * to keep track of various entities. */ load: function (params) { - this.initialGroupBys = params.initialGroupBys; + this.initialGroupBys = params.groupBys; this.fields = params.fields; this.modelName = params.modelName; - if (!params.groupedBy.length) { - var groupedBy = params.context.graph_groupbys || - (params.groupedBy.length && params.groupedBy) || - this.initialGroupBys; - params.groupedBy = groupedBy.slice(0); - } this.chart = { data: [], - groupedBy: params.groupedBy, - measure: params.initialMeasure, - mode: params.initialMode, + groupedBy: params.groupBys, + measure: params.measure, + mode: params.mode, domain: params.domain, context: params.context, }; @@ -130,13 +123,14 @@ return AbstractModel.extend({ if (this.chart.measure !== '__count__') { fields = fields.concat(this.chart.measure); } + var groupedBy = this.chart.groupedBy.length ? this.chart.groupedBy : this.initialGroupBys; return this._rpc({ model: this.modelName, method: 'read_group', context: this.chart.context, domain: this.chart.domain, fields: fields, - groupBy: this.chart.groupedBy, + groupBy: groupedBy, lazy: false, }) .then(this._processData.bind(this)); |
