From 611b4ed95aade192d9958549646bbfa2e11cae6a Mon Sep 17 00:00:00 2001 From: Nicolas Seinlet Date: Wed, 11 Dec 2019 08:49:33 +0000 Subject: [PATCH] [FIX] mail: fix activity view when having activities without type At model level, activity_type_id is not a mandatory field on mail.activity. Indeed required is added in views, meaning people could have activities without type. This make the activity views crash with `TypeError: 'bool' object is not subscriptable` error when computing aggregated activity data. This commit fixes that error. Activities without type are still not displayed in the activity view as columns are based on available activity types. It means activities without type have no column to be displayed. As this is a corner case that should not happen when using activities using the interface this is considered as a limitation of current implementation. closes odoo/odoo#42991 X-original-commit: 77f0dd8936df3dddfa3df8041d4b7f7c62595430 Signed-off-by: Thibault Delavallee (tde) --- addons/mail/models/mail_activity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 00857451c5f..7e8d52146ae 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -524,7 +524,7 @@ class MailActivity(models.Model): activity_data = defaultdict(dict) for group in grouped_activities: res_id = group['res_id'] - activity_type_id = group['activity_type_id'][0] + activity_type_id = (group.get('activity_type_id') or (False, False))[0] res_id_to_deadline[res_id] = group['date_deadline'] if (res_id not in res_id_to_deadline or group['date_deadline'] < res_id_to_deadline[res_id]) else res_id_to_deadline[res_id] state = self._compute_state_from_date(group['date_deadline'], self.user_id.sudo().tz) activity_data[res_id][activity_type_id] = {