summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/graph/graph_view.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-06-01 10:26:50 +0200
committerAaron Bohy <aab@odoo.com>2017-06-01 12:02:17 +0200
commit2f4d3d0e667092f70f44db03437473acf4ad5b32 (patch)
treec2391824366cbbcbf75d4de7fbed27ba9bfb88d3 /addons/web/static/src/js/views/graph/graph_view.js
parent033aec082669d6fb8126d6740b8aa7d09a2831d3 (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_view.js')
-rw-r--r--addons/web/static/src/js/views/graph/graph_view.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_view.js b/addons/web/static/src/js/views/graph/graph_view.js
index 1d4ee29ef63..08b5ce1968f 100644
--- a/addons/web/static/src/js/views/graph/graph_view.js
+++ b/addons/web/static/src/js/views/graph/graph_view.js
@@ -27,11 +27,11 @@ var GraphView = AbstractView.extend({
/**
* @override
*/
- init: function (viewInfo) {
+ init: function (viewInfo, params) {
this._super.apply(this, arguments);
- var initialMeasure = '__count__';
- var initialGroupBys = [];
+ var measure;
+ var groupBys = [];
viewInfo.fields = _.defaults({__count__: {string: _t("Count"), type: "integer"}}, viewInfo.fields);
viewInfo.arch.children.forEach(function (field) {
var name = field.attrs.name;
@@ -39,9 +39,9 @@ var GraphView = AbstractView.extend({
name += ':' + field.attrs.interval;
}
if (field.attrs.type === 'measure') {
- initialMeasure = name;
+ measure = name;
} else {
- initialGroupBys.push(name);
+ groupBys.push(name);
}
});
@@ -57,9 +57,9 @@ var GraphView = AbstractView.extend({
this.controllerParams.measures = measures;
this.rendererParams.stacked = viewInfo.arch.attrs.stacked !== "False";
- this.loadParams.initialMode = viewInfo.arch.attrs.type || 'bar';
- this.loadParams.initialMeasure = initialMeasure;
- this.loadParams.initialGroupBys = initialGroupBys;
+ this.loadParams.mode = params.context.graph_mode || viewInfo.arch.attrs.type || 'bar';
+ this.loadParams.measure = params.context.graph_measure || measure || '__count__';
+ this.loadParams.groupBys = params.context.graph_groupbys || groupBys || [];
this.loadParams.fields = viewInfo.fields;
},
});