diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 875a34aa92f..93e8d72cfe8 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -144,11 +144,15 @@ var BasicDataView = instance.web.Widget.extend({ // measure: quantity to display. either a field from the model, or // null, in which case we use the "count" measure init: function (model, options) { + var self = this; this.model = model; this.fields = options.fields; this.domain = options.domain; - this.row_groupby = options.row_groupby; - this.col_groupby = options.col_groupby; + this.groupby = { + row: options.row_groupby, + col: options.col_groupby, + }; + this.measure = options.measure; this.measure_label = options.measure ? options.fields[options.measure].string : 'Quantity'; this.data = []; @@ -166,12 +170,12 @@ var BasicDataView = instance.web.Widget.extend({ }, set_row_groupby: function (row_groupby) { - this.row_groupby = row_groupby; + this.groupby.row = row_groupby; this.need_redraw = true; }, set_col_groupby: function (col_groupby) { - this.col_groupby = col_groupby; + this.groupby.col = col_groupby; this.need_redraw = true; }, @@ -196,7 +200,7 @@ var BasicDataView = instance.web.Widget.extend({ }, get_data: function (groupby) { - var view_fields = this.row_groupby.concat(this.measure, this.col_groupby); + var view_fields = this.groupby.row.concat(this.measure, this.groupby.col); return query_groups(this.model, view_fields, this.domain, groupby); }, @@ -222,11 +226,11 @@ var PivotTable = BasicDataView.extend({ if (row.expanded) { this.fold_row(row_id); } else { - if (row.path.length < this.row_groupby.length) { - var field_to_expand = this.row_groupby[row.path.length]; + if (row.path.length < this.groupby.row.length) { + var field_to_expand = this.groupby.row[row.path.length]; this.expand_row(row_id, field_to_expand); } else { - var already_grouped = self.row_groupby.concat(self.col_groupby); + var already_grouped = self.groupby.row.concat(self.groupby.col); var possible_groups = _.difference(self.important_fields, already_grouped); var dropdown_options = { fields: _.map(possible_groups, function (field) { @@ -252,8 +256,8 @@ var PivotTable = BasicDataView.extend({ }, clear_groups: function () { - this.row_groupby = []; - this.col_groupby = []; + this.groupby.row = []; + this.groupby.col = []; this.rows = []; this.cols = []; this.draw(); @@ -305,7 +309,7 @@ var PivotTable = BasicDataView.extend({ } var indent_level = has_parent ? parent.path.length : 0; - var value = (this.row_groupby.length > 0) ? data.attributes.value[1] : 'Total'; + var value = (this.groupby.row.length > 0) ? data.attributes.value[1] : 'Total'; var jquery_row = $('