[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 <Julien00859@users.noreply.github.com>
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Julien Castiaux
2020-11-30 13:50:56 +00:00
parent 75aec1ef61
commit 62c11192bc
@@ -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: