From 9ad357553db14870c2a98c763d2526d78fa34063 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 11 Sep 2015 14:10:49 +0200 Subject: [PATCH] [FIX] mass_mailing: missing auto_commit in `send_mail` overrides The argument `auto_commit` was omitted in `send_mail` overrides. `auto_commit` was therefore allmost always `False` when reaching the `send` method of model `mail.mail`, in `mail/mail_mail.py`. At least it was when either `sale`, `purchase` or `account` were installed. Not committing the sql transaction leaded to the fact the mail statistics were never created when the queue process was interrupted (e.g. process time limit reached), and knowing if an email in a mass mailing has already been sent or not is based on the fact the mail statistics exists or not. Therefore, if a mass mailing sending process was interrupted, the emails were re-sent over and over. opw-649106 --- addons/account/account_invoice.py | 4 ++-- addons/purchase/purchase.py | 2 +- addons/sale/sale.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 51c815b0998..1a401f93198 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1656,7 +1656,7 @@ class mail_compose_message(models.Model): _inherit = 'mail.compose.message' @api.multi - def send_mail(self): + def send_mail(self, auto_commit=False): context = self._context if context.get('default_model') == 'account.invoice' and \ context.get('default_res_id') and context.get('mark_invoice_as_sent'): @@ -1664,4 +1664,4 @@ class mail_compose_message(models.Model): invoice = invoice.with_context(mail_post_autofollow=True) invoice.write({'sent': True}) invoice.message_post(body=_("Invoice sent")) - return super(mail_compose_message, self).send_mail() + return super(mail_compose_message, self).send_mail(auto_commit=auto_commit) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index b48c7b4aea1..744926b039e 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1753,7 +1753,7 @@ class mail_compose_message(osv.Model): if context.get('default_model') == 'purchase.order' and context.get('default_res_id'): context = dict(context, mail_post_autofollow=True) self.pool.get('purchase.order').signal_workflow(cr, uid, [context['default_res_id']], 'send_rfq') - return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) + return super(mail_compose_message, self).send_mail(cr, uid, ids, auto_commit=auto_commit, context=context) class account_invoice(osv.Model): diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 906d8baba01..cbcb9fc6f4e 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1216,7 +1216,7 @@ class mail_compose_message(osv.Model): if context.get('default_model') == 'sale.order' and context.get('default_res_id') and context.get('mark_so_as_sent'): context = dict(context, mail_post_autofollow=True) self.pool.get('sale.order').signal_workflow(cr, uid, [context['default_res_id']], 'quotation_sent') - return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) + return super(mail_compose_message, self).send_mail(cr, uid, ids, auto_commit=auto_commit, context=context) class account_invoice(osv.Model):