[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
This commit is contained in:
Denis Ledoux
2015-09-11 14:18:45 +02:00
parent 63a5bc8c5f
commit 9ad357553d
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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):
+1 -1
View File
@@ -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):