[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) <tde@openerp.com>
This commit is contained in:
Nicolas Seinlet
2020-01-08 18:14:36 +00:00
committed by Thibault Delavallée
parent 8c18433605
commit 611b4ed95a
+1 -1
View File
@@ -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] = {