[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
This commit is contained in:
Ankit Sathvara
2020-09-29 11:44:19 +00:00
committed by Thibault Delavallée
parent 9e647230a3
commit c075dfe44d
+4 -1
View File
@@ -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)