[IMP] mail: avoid sending an email twice
authorMartin Trigaux <mat@openerp.com>
Mon, 22 Sep 2014 15:48:11 +0000 (17:48 +0200)
committerMartin Trigaux <mat@openerp.com>
Mon, 22 Sep 2014 16:16:48 +0000 (18:16 +0200)
commit506e397e4a65cfca95f978ac53a63524d13443ba
treec60a42d4a3b56733ad3f540178e8b17ae53197ab
parentc6290988ce6b42013086d67d5dfa165b9aa3c40a
[IMP] mail: avoid sending an email twice

In some specific conditions (e.g. admin logging during cron run, concurrent update), writing on the mail object may fail, triggering a rollback of the transaction.
As the write was done after the SMTP sendmail action, an email could be sent twice (state not correctly put, would be retried at next process of the email queue).
This patch provoke the error before the sendmail action and thus avoids sending the email.
Fixes #552
addons/mail/mail_mail.py