Skip to content

Commit

Permalink
[FIX] mass_mailing: missing auto_commit in send_mail overrides
Browse files Browse the repository at this point in the history
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
  • Loading branch information
beledouxdenis committed Sep 11, 2015
1 parent 63a5bc8 commit 9ad3575
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions addons/account/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,12 +1656,12 @@ 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'):
invoice = self.env['account.invoice'].browse(context['default_res_id'])
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)
2 changes: 1 addition & 1 deletion addons/purchase/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ def send_mail(self, cr, uid, ids, auto_commit=False, context=None):
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):
Expand Down
2 changes: 1 addition & 1 deletion addons/sale/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ def send_mail(self, cr, uid, ids, auto_commit=False, context=None):
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):
Expand Down

0 comments on commit 9ad3575

Please sign in to comment.