From 62c11192bcaab4c31aabdd6954e94ab39fa42546 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Fri, 7 Feb 2020 10:12:42 +0000 Subject: [PATCH] [FIX] base_automation: warn email are not compatible with unlink Create a automated action on deletion that send an email, delete a related record. The email is not sent. Email are linked to their chatter message, when the later is deleted the former is deleted in cascade too. This is a known limitation of the mail model. closes odoo/odoo#62616 Task: 2151519 X-original-commit: f8904eb19d82d1d255c1ef091d1e47e0e016a62f Signed-off-by: Julien Castiaux Signed-off-by: Raphael Collet (rco) --- addons/base_automation/models/base_automation.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/base_automation/models/base_automation.py b/addons/base_automation/models/base_automation.py index 2fd82b39388..e21df36ee9a 100644 --- a/addons/base_automation/models/base_automation.py +++ b/addons/base_automation/models/base_automation.py @@ -107,6 +107,16 @@ class BaseAutomation(models.Model): } }} + MAIL_STATES = ('email', 'followers', 'next_activity') + if self.trigger == 'on_unlink' and self.state in MAIL_STATES: + return {'warning': { + 'title': _("Warning"), + 'message': _( + "You cannot send an email, add followers or create an activity " + "for a deleted record. It simply does not work." + ), + }} + @api.model_create_multi def create(self, vals_list): for vals in vals_list: