summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_thread.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-08-21 10:10:11 +0200
committerChristophe Simonis <chs@odoo.com>2019-08-21 10:10:11 +0200
commit3faea8fbf810224ad4e03cfa1dc36f186800c501 (patch)
tree5e05c40d62dacc5951c70b3686f30a7bbb86f399 /addons/mail/models/mail_thread.py
parentcc2d78beeaf61fa0b8c9543196d1b4fce5cd5da6 (diff)
parentf26de445e5579913e27ea6a630bcee6d40eefc7d (diff)
[MERGE] forward port branch saas-12.4 up to f26de445e55
Diffstat (limited to 'addons/mail/models/mail_thread.py')
-rw-r--r--addons/mail/models/mail_thread.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 2016f07e0c3..80b4db5131b 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -878,7 +878,7 @@ class MailThread(models.AbstractModel):
# compute references to find if message is a reply to an existing thread
thread_references = message_dict['references'] or message_dict['in_reply_to']
msg_references = [ref for ref in tools.mail_header_msgid_re.findall(thread_references) if 'reply_to' not in ref]
- mail_messages = self.env['mail.message'].sudo().search([('message_id', 'in', msg_references)], limit=1)
+ mail_messages = self.env['mail.message'].sudo().search([('message_id', 'in', msg_references)], limit=1, order='id desc, message_id')
is_a_reply = bool(mail_messages)
reply_model, reply_thread_id = mail_messages.model, mail_messages.res_id
@@ -1366,7 +1366,7 @@ class MailThread(models.AbstractModel):
# Very unusual situation, be we should be fault-tolerant here
message_id = "<%s@localhost>" % time.time()
_logger.debug('Parsing Message without message-id, generating a random one: %s', message_id)
- msg_dict['message_id'] = message_id
+ msg_dict['message_id'] = message_id.strip()
if message.get('Subject'):
msg_dict['subject'] = tools.decode_message_header(message, 'Subject')