From 92dcbfe8d06927ce0a7afb2dddd9eeea22b3735b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 6 Aug 2018 12:02:33 +0200 Subject: [PATCH] [IMP] mail: add method to send an email on activity mixin Purpose of this commit is to have a shortcut allowing to send an email based on an email template in the activity mixin. Its use will be to integrate the sending of emails directly in chatter-activity widget. This commit is linked to task ID 1872169 and PR #26185. --- addons/mail/models/mail_activity.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 72263a134c0..9fc7907aae4 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -495,6 +495,19 @@ class MailActivityMixin(models.AbstractModel): ]).unlink() return super(MailActivityMixin, self).toggle_active() + def activity_send_mail(self, template_id): + """ Automatically send an email based on the given mail.template, given + its ID. """ + template = self.env['mail.template'].browse(template_id).exists() + if not template: + return False + for record in self: + record.message_post_with_template( + template_id, + composition_mode='comment' + ) + return True + def activity_schedule(self, act_type_xmlid='', date_deadline=None, summary='', note='', **act_values): """ Schedule an activity on each record of the current record set. This method allow to provide as parameter act_type_xmlid. This is an