diff options
| author | Srushti Patel <shp@odoo.com> | 2015-07-30 12:54:01 +0530 |
|---|---|---|
| committer | David Monjoie <dmo@odoo.com> | 2015-08-19 10:40:39 +0200 |
| commit | 2feaa4c15b470f14c49194875fbde323848dc481 (patch) | |
| tree | d51733297e1bf5cb54f8b976b3f9b891a894199d /addons/web/static/src | |
| parent | a3d2acb66c451ca48d167a4910c7cac3e89f7bf0 (diff) | |
[IMP] web: sorted custom group by items
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/search_menus.js | 14 | ||||
| -rw-r--r-- | 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 @@ <t t-name="GroupByMenuSelector"> <li><select class="form-control oe-add-group oe-group-selector"> <t t-foreach="groupable_fields" t-as="field"> - <option t-att-data-name="field"><t t-esc="groupable_fields[field].string"/></option> + <option t-att-data-name="field.name"><t t-esc="field.string"/></option> </t> </select></li> <li><button type="button" class="btn btn-default oe-add-group oe-select-group">Apply</button></li> |
