From 2feaa4c15b470f14c49194875fbde323848dc481 Mon Sep 17 00:00:00 2001 From: Srushti Patel Date: Thu, 30 Jul 2015 12:54:01 +0530 Subject: [PATCH] [IMP] web: sorted custom group by items --- addons/web/static/src/js/views/search_menus.js | 14 +++++++------- addons/web/static/src/xml/base.xml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/js/views/search_menus.js b/addons/web/static/src/js/views/search_menus.js index 208a50754fc..cd833bfdebe 100644 --- a/addons/web/static/src/js/views/search_menus.js +++ b/addons/web/static/src/js/views/search_menus.js @@ -388,7 +388,7 @@ return Widget.extend({ init: function (parent, groups, fields_def) { this._super(parent); this.groups = groups || []; - this.groupable_fields = {}; + this.groupable_fields = []; this.searchview = parent; this.fields_def = fields_def.then(this.proxy('get_groupable_fields')); }, @@ -413,14 +413,14 @@ return Widget.extend({ }); }, get_groupable_fields: function (fields) { - var self = this, - groupable_types = ['many2one', 'char', 'boolean', 'selection', 'date', 'datetime']; - - _.each(fields, function (field, name) { + var groupable_types = ['many2one', 'char', 'boolean', 'selection', 'date', 'datetime']; + var filter_group_field = _.filter(fields, function(field, name) { if (field.store && _.contains(groupable_types, field.type)) { - self.groupable_fields[name] = field; + field.name = name; + return field; } }); + this.groupable_fields = _.sortBy(filter_group_field, 'string'); }, toggle_add_menu: function (is_open) { this.$add_group @@ -434,7 +434,7 @@ return Widget.extend({ add_groupby_to_menu: function (field_name) { var filter = new search_inputs.Filter({attrs:{ context:"{'group_by':'" + field_name + "''}", - name: this.groupable_fields[field_name].string, + name: _.find(this.groupable_fields, {name: field_name}).string, }}, this.searchview); var group = new search_inputs.FilterGroup([filter], this.searchview), divider = this.$('.divider').show(); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 51051081419..7c560c3557f 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1185,7 +1185,7 @@