From 050ad8e189f197ed18670ac73efe0413dd0df751 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Thu, 2 May 2019 12:39:02 +0000 Subject: [PATCH] [FIX] mail: clean context when running email action The action_subtask method adds 'default_parent_id' to the context. If the creation or edition of a subtasks triggers an email creation, (e.g. if there is an automated action 'send email') the default 'default_parent_id' is still in the context. Therefore, it tries to create the email with an arbitrary foreign key (since it is an existing record on the project.task model), or crashes. Similar to 816f3861. opw 1978498 closes odoo/odoo#33111 Signed-off-by: Nans Lefebvre (len) --- addons/mail/models/ir_actions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mail/models/ir_actions.py b/addons/mail/models/ir_actions.py index 40582b1d803..203304c7fb7 100644 --- a/addons/mail/models/ir_actions.py +++ b/addons/mail/models/ir_actions.py @@ -112,6 +112,7 @@ class ServerActions(models.Model): # with wrong values in subsequent operations cleaned_ctx = dict(self.env.context) cleaned_ctx.pop('default_type', None) + cleaned_ctx.pop('default_parent_id', None) action.template_id.with_context(cleaned_ctx).send_mail(self._context.get('active_id'), force_send=False, raise_exception=False) return False