summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-12-02 12:33:41 +0000
committerThibault Delavallée <tde@odoo.com>2019-12-02 15:18:44 +0000
commit82f56ffddfc6aed21030214dc95c0a3e9f5d9a93 (patch)
treedbe48123fc15fb5b8a9b3948abe17f74e631ea35
parent5649fc88e8f3022f4143400a124f2e3c1e5c0df8 (diff)
[IMP] mail: simplify parent and parent internal computation in routing
PURPOSE Clean posting process and improve mail.message definition and comprehension. SPECIFICATIONS In this commit we use the is_internal flag to correctly propagate it from mail gateway and clean some parent check. In this commit some code is cleaned. No functional change should occur with this commit. LINKS Task ID 2071556 PR #38692
-rw-r--r--addons/mail/models/mail_thread.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 91e9c7e16a1..6ca54653d87 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -1437,18 +1437,15 @@ class MailThread(models.AbstractModel):
stored_date = datetime.datetime.now()
msg_dict['date'] = stored_date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
+ parent_ids = False
if msg_dict['in_reply_to']:
parent_ids = self.env['mail.message'].search([('message_id', '=', msg_dict['in_reply_to'])], limit=1)
- if parent_ids:
- msg_dict['parent_id'] = parent_ids.id
- msg_dict['is_internal'] = parent_ids.subtype_id and parent_ids.subtype_id.internal or False
-
- if msg_dict['references'] and 'parent_id' not in msg_dict:
+ if msg_dict['references'] and not parent_ids:
references_msg_id_list = tools.mail_header_msgid_re.findall(msg_dict['references'])
parent_ids = self.env['mail.message'].search([('message_id', 'in', [x.strip() for x in references_msg_id_list])], limit=1)
- if parent_ids:
- msg_dict['parent_id'] = parent_ids.id
- msg_dict['is_internal'] = parent_ids.subtype_id and parent_ids.subtype_id.internal or False
+ if parent_ids:
+ msg_dict['parent_id'] = parent_ids.id
+ msg_dict['is_internal'] = parent_ids.subtype_id and parent_ids.subtype_id.internal or False
msg_dict.update(self._message_parse_extract_payload(message, save_original=save_original))
msg_dict.update(self._message_parse_extract_bounce(message, msg_dict))