From c075dfe44d3f5b7c8cc54e8f466332553bffcd2b Mon Sep 17 00:00:00 2001 From: Ankit Sathvara Date: Tue, 1 Sep 2020 11:05:54 +0000 Subject: [PATCH] [FIX] mail: allow to create next activities when not having a clear model as context Before this commit, when we tried to launch next activity from the already scheduled actvity's popover on chatter (activity that do have a next activity set on it), it resulted into a traceback. This was due to a recent commit[1] trying to set the default activity type. This commit fixes the issue by improving method setting the default activity type and thus allowing to schedule next activity from popover. [1] - https://github.com/odoo/odoo/commit/9a8fdda8ab09e2a8394a2bf3bf7acbc349b112ad Task ID-2302572 X-original-commit: e341980b191d0b044662b3de5f3bbc78cf3a0876 --- addons/mail/models/mail_activity.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index f79d0c44a11..57e029db488 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -124,7 +124,10 @@ class MailActivity(models.Model): def _default_activity_type_id(self): ActivityType = self.env["mail.activity.type"] activity_type_todo = self.env.ref('mail.mail_activity_data_todo', raise_if_not_found=False) - current_model_id = self.default_get(['res_model_id', 'res_model'])['res_model_id'] + default_vals = self.default_get(['res_model_id', 'res_model']) + if not default_vals.get('res_model_id'): + return ActivityType + current_model_id = default_vals['res_model_id'] if activity_type_todo and activity_type_todo.active and (activity_type_todo.res_model_id.id == current_model_id or not activity_type_todo.res_model_id): return activity_type_todo activity_type_model = ActivityType.search([('res_model_id', '=', current_model_id)], limit=1)