diff options
| author | Manuel Vázquez Acosta <mva.led@gmail.com> | 2014-10-03 09:19:30 -0400 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2014-11-04 17:32:32 +0100 |
| commit | 2fb2d9f956b5ddd37da3cc3fdb9f55ea1f0e1878 (patch) | |
| tree | 113b951df68f14b8f4f2abcbe9b63f86f1863303 /addons/mail/mail_mail.py | |
| parent | 42cdf0071e7471a682b6af5de530eb9b1f8e5dff (diff) | |
[FIX] mail: partners with missing/invalid emails must not halt notifications to others
Diffstat (limited to 'addons/mail/mail_mail.py')
| -rw-r--r-- | addons/mail/mail_mail.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 1c53d0477a7..b71176bcd08 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -305,8 +305,23 @@ class mail_mail(osv.Model): object_id = mail.res_id and ('%s-%s' % (mail.res_id, mail.model)), subtype = 'html', subtype_alternative = 'plain') - res = ir_mail_server.send_email(cr, uid, msg, - mail_server_id=mail.mail_server_id.id, context=context) + try: + res = ir_mail_server.send_email( + cr, uid, + msg, + mail_server_id=mail.mail_server_id.id, + context=context + ) + except AssertionError as error: + if error.message == ir_mail_server.NO_VALID_RECIPIENT: + # No valid recipient found for this particular + # mail item -> ignore error to avoid blocking + # delivery to next recipients, if any. If this is + # the only recipient, the mail will show as failed. + _logger.warning("Ignoring invalid recipients for mail.mail %s: %s", + mail.message_id, email.get('email_to')) + else: + raise if res: mail.write({'state': 'sent', 'message_id': res}) mail_sent = True |
