summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/graph_view.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_graph/static/src/js/graph_view.js')
-rw-r--r--addons/web_graph/static/src/js/graph_view.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/addons/web_graph/static/src/js/graph_view.js b/addons/web_graph/static/src/js/graph_view.js
index e1a50d4ff6d..b39ac105ee4 100644
--- a/addons/web_graph/static/src/js/graph_view.js
+++ b/addons/web_graph/static/src/js/graph_view.js
@@ -50,7 +50,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
var field_name = field.attrs.name;
if (_.has(field.attrs, 'interval')) {
field_name = field.attrs.name + ':' + field.attrs.interval;
- }
+ }
if (_.has(field.attrs, 'type')) {
switch (field.attrs.type) {
case 'row':
@@ -78,14 +78,14 @@ instance.web_graph.GraphView = instance.web.View.extend({
do_search: function (domain, context, group_by) {
var self = this,
- col_group_by = context.col_group_by || this.get_groupbys_from_searchview('ColGroupBy', 'col_group_by');
+ col_group_by = this.extract_groupby('col_group_by', context) || [];
if (!this.graph_widget) {
if (group_by.length) {
this.widget_config.row_groupby = group_by;
}
if (col_group_by.length) {
- this.widget_config.col_groupby = group_by;
+ this.widget_config.col_groupby = col_group_by;
}
this.graph_widget = new openerp.web_graph.Graph(this, this.model, domain, this.widget_config);
this.graph_widget.appendTo(this.$el);
@@ -101,16 +101,18 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.graph_widget.set(domain, group_by, col_group_by);
},
+ extract_groupby: function (cat_field, context) {
+ context = (_.isString(context)) ? py.eval(context) : context;
+ return context[cat_field];
+ },
+
get_groupbys_from_searchview: function (cat_name, cat_field) {
- var facet = this.search_view.query.findWhere({category:cat_name}),
+ var self=this,
+ facet = this.search_view.query.findWhere({category:cat_name}),
groupby_list = facet ? facet.values.models : [];
return _.map(groupby_list, function (g) {
var context = g.attributes.value.attrs.context;
- if (_.isString(context)) {
- return py.eval(context).group_by;
- } else {
- return context[cat_field];
- }
+ return self.extract_groupby(cat_field, context);
});
},