[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.
This commit is contained in:
Thibault Delavallée
2018-08-06 16:24:43 +02:00
parent 967d228a44
commit 92dcbfe8d0
+13
View File
@@ -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