summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/graph_view.js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2014-02-07 14:53:39 +0100
committerGery Debongnie <ged@openerp.com>2014-02-07 14:53:39 +0100
commit88b7511f6883ed42e113f818449fb2fa61c9c40b (patch)
tree32fea9a00ba48185f3f3008c95bab8f6ad7c5d04 /addons/web_graph/static/src/js/graph_view.js
parent79caa8e186645a5584d9cdd8c7779a35a1f29b9e (diff)
[FIX] correctly use the col group by instead of groupby when reading the context and initializing a graph view (addon web_graph)
bzr revid: ged@openerp.com-20140207135339-ohrjh6uvu22tjavh
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);
});
},