diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 36b86cb0098..93c0dd7c40c 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2470,6 +2470,15 @@ var BasicModel = AbstractModel.extend({ aggregateValues[key] = value; } }); + // When a view is grouped, we need to display the name of each group in + // the 'title'. + var value = group[rawGroupBy]; + if (list.fields[rawGroupBy].type === "selection") { + var choice = _.find(list.fields[rawGroupBy].selection, function (c) { + return c[0] === value; + }); + value = choice[1]; + } var newGroup = self._makeDataPoint({ modelName: list.model, count: group[rawGroupBy + '_count'], @@ -2477,7 +2486,7 @@ var BasicModel = AbstractModel.extend({ context: list.context, fields: list.fields, fieldsInfo: list.fieldsInfo, - value: group[rawGroupBy], + value: value, aggregateValues: aggregateValues, groupedBy: list.groupedBy.slice(1), orderedBy: list.orderedBy, diff --git a/addons/web/static/src/js/views/kanban/kanban_column.js b/addons/web/static/src/js/views/kanban/kanban_column.js index 0ba08d08b1a..642ab2e8aeb 100644 --- a/addons/web/static/src/js/views/kanban/kanban_column.js +++ b/addons/web/static/src/js/views/kanban/kanban_column.js @@ -39,12 +39,8 @@ var KanbanColumn = Widget.extend({ var value = data.value; this.id = data.res_id || value; - var field = data.fields[data.groupedBy[0]]; // fixme: grouped by field might not be in the fvg - if (field && field.type === "selection") { - value = _.find(field.selection, function (s) { return s[0] === data.value; })[1]; // fixme: same process done in list_renderer - } // todo: handle group_by_m2o (nameget) - this.title = value || _t('Undefined'); + this.title = value === undefined ? _t('Undefined') : value; this.folded = !data.isOpen; this.has_active_field = 'active' in data.fields; this.size = data.count; diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js index 2305530affe..3cda7e9f809 100644 --- a/addons/web/static/src/js/views/list/list_renderer.js +++ b/addons/web/static/src/js/views/list/list_renderer.js @@ -172,24 +172,6 @@ var ListRenderer = BasicRenderer.extend({ return decoration.replace('decoration', 'text'); }).value(); }, - /** - * When a list view is grouped, we need to display the name of each group in - * the 'title' row. This is the purpose of this method. - * - * @private - * @param {any} value - * @param {Object} field a field description - * @returns {string} - */ - _formatValue: function (value, field) { - if (field && field.type === 'selection') { - var choice = _.find(field.selection, function (c) { - return c[0] === value; - }); - return choice[1]; - } - return value || _t('Undefined'); - }, /** * return the number of visible columns. Note that this number depends on * the state of the renderer. For example, in editable mode, it could be @@ -409,8 +391,7 @@ var ListRenderer = BasicRenderer.extend({ if (this.hasSelectors) { $cells.unshift($('')); } - var field = this.state.fields[this.state.groupedBy[groupLevel]]; - var name = this._formatValue(group.value, field); + var name = group.value === undefined ? _t('Undefined') : group.value; var $th = $('') .addClass('o_group_name') .text(name + ' (' + group.count + ')');