diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 4a29e788d95..9838b96a5cd 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -422,8 +422,10 @@ class MailActivity(models.Model): @api.model def get_activity_data(self, res_model, domain): - res = self.env[res_model].search(domain) - activity_domain = [('res_id', 'in', res.ids), ('res_model', '=', res_model)] + activity_domain = [('res_model', '=', res_model)] + if domain: + res = self.env[res_model].search(domain) + activity_domain.append(('res_id', 'in', res.ids)) grouped_activities = self.env['mail.activity'].read_group( activity_domain, ['res_id', 'activity_type_id', 'res_name:max(res_name)', 'ids:array_agg(id)', 'date_deadline:min(date_deadline)'], @@ -443,7 +445,6 @@ class MailActivity(models.Model): state = self._compute_state_from_date(group['date_deadline'], self.user_id.sudo().tz) activity_data[res_id][activity_type_id] = { 'count': group['__count'], - 'domain': group['__domain'], 'ids': group['ids'], 'state': state, 'o_closest_deadline': group['date_deadline'], diff --git a/addons/web/models/models.py b/addons/web/models/models.py index 572f07333d2..2e3bd54788d 100644 --- a/addons/web/models/models.py +++ b/addons/web/models/models.py @@ -40,11 +40,14 @@ class Base(models.AbstractModel): records_values = self.search_read(domain or [], [progress_bar['field'], group_by]) data = {} + field_type = self._fields[group_by].type + if field_type == 'selection': + selection_labels = dict(self.fields_get()[group_by]['selection']) + for record_values in records_values: group_by_value = record_values[group_by] # Again, imitating what _read_group_format_result and _read_group_prepare_data do - field_type = self._fields[group_by].type if group_by_value and field_type in ['date', 'datetime']: locale = self._context.get('lang') or 'en_US' group_by_value = fields.Datetime.to_datetime(group_by_value) @@ -61,7 +64,7 @@ class Base(models.AbstractModel): locale=locale) if field_type == 'selection': - group_by_value = dict(self.fields_get()[group_by]['selection'])[group_by_value] + group_by_value = selection_labels[group_by_value] if type(group_by_value) == tuple: group_by_value = group_by_value[1] # FIXME should use technical value (0) diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js index fd21ed4df86..bfb6f5e0cc9 100644 --- a/addons/web/static/src/js/views/kanban/kanban_model.js +++ b/addons/web/static/src/js/views/kanban/kanban_model.js @@ -305,7 +305,7 @@ var KanbanModel = BasicModel.extend({ * @override */ _load: function (dataPoint, options) { - if (dataPoint.progressBar) { + if (dataPoint.groupedBy.length && dataPoint.progressBar) { return this._readProgressBarGroup(dataPoint, options); } return this._super.apply(this, arguments); diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js index f8f2e232794..84d63fa4f67 100644 --- a/addons/web/static/tests/views/kanban_tests.js +++ b/addons/web/static/tests/views/kanban_tests.js @@ -4232,6 +4232,37 @@ QUnit.module('Views', { kanban.destroy(); }); + QUnit.test('column progressbars should not crash in non grouped views', function (assert) { + assert.expect(3); + + var kanban = createView({ + View: KanbanView, + model: 'partner', + data: this.data, + arch: + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '
' + + '
', + mockRPC: function (route, args) { + assert.step(route) + return this._super(route, args); + }, + }); + + assert.strictEqual(kanban.$('.o_kanban_record').text(), 'namenamenamename', + "should have renderer 4 records"); + + assert.verifySteps(['/web/dataset/search_read'], "no read on progress bar data is done"); + kanban.destroy(); + }); + QUnit.test('column progressbars: creating a new column should create a new progressbar', function (assert) { assert.expect(1);