diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-04-09 12:16:06 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-04-09 12:16:06 +0200 |
| commit | 6c8e30cae6ca5e4fe12e287ebd29d76544be57a3 (patch) | |
| tree | cce147099046ba971a817b2a5b70fbd2f054c9d0 /addons/mail | |
| parent | 288d82a67137e206d30aaf572584e99cbee997b2 (diff) | |
| parent | 6d4940675f18dbb98d1f3882863ee10e7a1e3a49 (diff) | |
[MERGE] forward port branch saas-12.1 up to 6d4940675f1
Diffstat (limited to 'addons/mail')
| -rw-r--r-- | addons/mail/models/mail_mail.py | 12 | ||||
| -rw-r--r-- | addons/mail/models/mail_message.py | 4 | ||||
| -rw-r--r-- | addons/mail/models/mail_thread.py | 2 |
3 files changed, 10 insertions, 8 deletions
diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index f758456c77e..a2ba820656f 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -5,6 +5,7 @@ import base64 import datetime import logging import psycopg2 +import smtplib import threading import re @@ -394,11 +395,12 @@ class MailMail(models.Model): mail.id, mail.message_id) # mail status will stay on ongoing since transaction will be rollback raise - except psycopg2.Error: - # If an error with the database occurs, chances are that the cursor is unusable. - # This will lead to an `psycopg2.InternalError` being raised when trying to write - # `state`, shadowing the original exception and forbid a retry on concurrent - # update. Let's bubble it. + except (psycopg2.Error, smtplib.SMTPServerDisconnected): + # If an error with the database or SMTP session occurs, chances are that the cursor + # or SMTP session are unusable, causing further errors when trying to save the state. + _logger.exception( + 'Exception while processing mail with ID %r and Msg-Id %r.', + mail.id, mail.message_id) raise except Exception as e: failure_reason = tools.ustr(e) diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index e228f7c4062..e2ebb16c69e 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -154,8 +154,8 @@ class Message(models.Model): @api.multi def _search_has_error(self, operator, operand): if operator == '=' and operand: - return ['&', ('notification_ids.email_status', 'in', ('bounce', 'exception')), ('author_id', '=', self.env.user.partner_id.id)] - return ['!', '&', ('notification_ids.email_status', 'in', ('bounce', 'exception')), ('author_id', '=', self.env.user.partner_id.id)] # this wont work and will be equivalent to "not in" beacause of orm restrictions. Dont use "has_error = False" + return [('notification_ids.email_status', 'in', ('bounce', 'exception'))] + return ['!', ('notification_ids.email_status', 'in', ('bounce', 'exception'))] # this wont work and will be equivalent to "not in" beacause of orm restrictions. Dont use "has_error = False" @api.depends('starred_partner_ids') def _get_starred(self): diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 79cfb230a6b..8e35a8fda18 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -237,7 +237,7 @@ class MailThread(models.AbstractModel): @api.model def _search_message_has_error(self, operator, operand): - return [('message_ids.has_error', operator, operand)] + return ['&', ('message_ids.has_error', operator, operand), ('message_ids.author_id', '=', self.env.user.partner_id.id)] @api.multi def _compute_message_attachment_count(self): |
