[FIX] fixes two small issues concerning the groupby dates in graph view (addon web_graph)

bzr revid: ged@openerp.com-20140124125944-wxl4zdya37pxdnqv
This commit is contained in:
Gery Debongnie
2014-01-24 13:59:44 +01:00
parent 29d08d9a6b
commit 524324ae4e
2 changed files with 17 additions and 13 deletions
+14 -10
View File
@@ -23,7 +23,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
this.bar_ui = options.bar_ui || 'group';
this.graph_view = options.graph_view || null;
this.pivot_options = options;
this.important_fields = this.get_search_fields();
},
start: function() {
@@ -44,6 +43,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
return this.model.call('fields_get', []).then(function (f) {
self.fields = f;
self.fields.__count = {field:'__count', type: 'integer', string:'Quantity'};
self.important_fields = self.get_search_fields();
self.measure_list = self.get_measures();
self.add_measures_to_options();
self.pivot_options.row_groupby = self.create_field_values(self.pivot_options.row_groupby || []);
@@ -69,6 +69,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
// this method gets the fields that appear in the search view, under the
// 'Groupby' heading
get_search_fields: function () {
var self = this;
var search_view = openerp.client.action_manager.inner_widget.searchview;
var groupbygroups = _(search_view.inputs).select(function (g) {
@@ -77,13 +78,15 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
var filters = [].concat.apply([], _.pluck(groupbygroups, 'filters'));
return _.map(filters, function (filter) {
return {
field: py.eval(filter.attrs.context).group_by,
string: filter.attrs.string,
filter: filter
};
});
return _.uniq(_.map(filters, function (filter) {
console.log(filter);
var field = py.eval(filter.attrs.context).group_by,
raw_field = field.split(':')[0],
string = (field === raw_field) ? filter.attrs.string : self.fields[raw_field].string,
filter = (field === raw_field) ? filter : undefined;
return { field: raw_field, string: string, filter: filter };
}), false, function (filter) {return filter.field;});
},
// Extracts the integer/float fields which are not 'id'
@@ -281,10 +284,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
if (!this.important_fields.length) {
return;
}
var fields = _.map(this.important_fields, function (field) {
return {id: field.field, value: field.string, type:self.fields[field.field].type};
return {id: field.field, value: field.string, type:self.fields[field.field.split(':')[0]].type};
});
debugger;
this.dropdown = $(QWeb.render('field_selection', {fields:fields, header_id:id}));
$(event.target).after(this.dropdown);
this.dropdown.css({position:'absolute',
@@ -402,12 +402,12 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
value = attrs.value,
grouped_on = attrs.grouped_on ? this.raw_field(attrs.grouped_on) : false;
if (grouped_on && this.fields[grouped_on].type === 'selection') {
if (value === false) {
group.attributes.value = 'undefined';
} else if (grouped_on && this.fields[grouped_on].type === 'selection') {
var selection = this.fields[grouped_on].selection,
value_lookup = _.where(selection, {0:value});
group.attributes.value = value_lookup ? value_lookup[0][1] : 'undefined';
} else if (value === false) {
group.attributes.value = 'undefined';
} else if (value instanceof Array) {
group.attributes.value = value[1];
}