From 553954fa82d1826443424334033c94968da91c8f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 25 Apr 2016 17:10:21 +0200 Subject: [PATCH] [ADD] mail: parameter on send_mail method To avoid to use the context to pass additional arguments just to specify recipients or other mail.message field values. --- addons/mail/models/mail_template.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py index 807f585de30..cf504a22579 100644 --- a/addons/mail/models/mail_template.py +++ b/addons/mail/models/mail_template.py @@ -519,7 +519,7 @@ class MailTemplate(models.Model): return multi_mode and results or results[res_ids[0]] @api.multi - def send_mail(self, res_id, force_send=False, raise_exception=False): + def send_mail(self, res_id, force_send=False, raise_exception=False, email_values=None): """Generates a new mail message for the given template and record, and schedules it for delivery through the ``mail`` module's scheduler. @@ -528,6 +528,8 @@ class MailTemplate(models.Model): :param bool force_send: if True, the generated mail.message is immediately sent after being created, as if the scheduler was executed for this message only. + :param dict email_values: if set, the generated mail.message is + updated with given values dict :returns: id of the mail.message that was created """ self.ensure_one() @@ -537,6 +539,7 @@ class MailTemplate(models.Model): # create a mail_mail based on values, without attachments values = self.generate_email(res_id) values['recipient_ids'] = [(4, pid) for pid in values.get('partner_ids', list())] + values.update(email_values or {}) attachment_ids = values.pop('attachment_ids', []) attachments = values.pop('attachments', []) # add a protection against void email_from