summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/graph
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-08-31 12:55:41 +0200
committerChristophe Simonis <chs@odoo.com>2017-08-31 12:55:41 +0200
commit4879ce040797fd4a47b6b8326c3aacd365c8ab91 (patch)
tree45479b47c5dcfba0d0ced4f05d770b0852f31263 /addons/web/static/src/js/views/graph
parentdae6178a0a5629ce678b20fcc9226caa44a5b0ce (diff)
parentfe77df3ba480d40b3d6b25736397bd52c684ce03 (diff)
[MERGE] forward port branch saas-17 up to fe77df3ba48
Diffstat (limited to 'addons/web/static/src/js/views/graph')
-rw-r--r--addons/web/static/src/js/views/graph/graph_controller.js10
-rw-r--r--addons/web/static/src/js/views/graph/graph_model.js15
-rw-r--r--addons/web/static/src/js/views/graph/graph_view.js8
3 files changed, 25 insertions, 8 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_controller.js b/addons/web/static/src/js/views/graph/graph_controller.js
index d68808bac1d..77e3f1e7a40 100644
--- a/addons/web/static/src/js/views/graph/graph_controller.js
+++ b/addons/web/static/src/js/views/graph/graph_controller.js
@@ -102,10 +102,20 @@ var GraphController = AbstractController.extend({
});
},
/**
+ * @private
+ */
+ _update: function () {
+ this._updateButtons();
+ return this._super.apply(this, arguments);
+ },
+ /**
* makes sure that the buttons in the control panel matches the current
* state (so, correct active buttons and stuff like that)
*/
_updateButtons: function () {
+ if (!this.$buttons) {
+ return;
+ }
var state = this.model.get();
this.$buttons.find('.o_graph_button').removeClass('active');
this.$buttons
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 50e9f224697..a6d2b057d0e 100644
--- a/addons/web/static/src/js/views/graph/graph_model.js
+++ b/addons/web/static/src/js/views/graph/graph_model.js
@@ -55,14 +55,15 @@ return AbstractModel.extend({
* to keep track of various entities.
*/
load: function (params) {
- this.initialGroupBys = params.groupBys;
+ var groupBys = params.context.graph_groupbys || params.groupBys;
+ this.initialGroupBys = groupBys;
this.fields = params.fields;
this.modelName = params.modelName;
this.chart = {
data: [],
- groupedBy: params.groupedBy.length ? params.groupedBy : params.groupBys,
- measure: params.measure,
- mode: params.mode,
+ groupedBy: params.groupedBy.length ? params.groupedBy : groupBys,
+ measure: params.context.graph_measure || params.measure,
+ mode: params.context.graph_mode || params.mode,
domain: params.domain,
context: params.context,
};
@@ -85,6 +86,12 @@ return AbstractModel.extend({
* @returns {Deferred}
*/
reload: function (handle, params) {
+ if ('context' in params) {
+ this.chart.context = params.context;
+ this.chart.groupedBy = params.context.graph_groupbys || this.chart.groupedBy;
+ this.chart.measure = params.context.graph_measure || this.chart.measure;
+ this.chart.mode = params.context.graph_mode || this.chart.mode;
+ }
if ('domain' in params) {
this.chart.domain = params.domain;
}
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 08b5ce1968f..423d52ca64c 100644
--- a/addons/web/static/src/js/views/graph/graph_view.js
+++ b/addons/web/static/src/js/views/graph/graph_view.js
@@ -27,7 +27,7 @@ var GraphView = AbstractView.extend({
/**
* @override
*/
- init: function (viewInfo, params) {
+ init: function (viewInfo) {
this._super.apply(this, arguments);
var measure;
@@ -57,9 +57,9 @@ var GraphView = AbstractView.extend({
this.controllerParams.measures = measures;
this.rendererParams.stacked = viewInfo.arch.attrs.stacked !== "False";
- 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.mode = viewInfo.arch.attrs.type || 'bar';
+ this.loadParams.measure = measure || '__count__';
+ this.loadParams.groupBys = groupBys || [];
this.loadParams.fields = viewInfo.fields;
},
});