diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 599cec0493c..a733f2f329b 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1109,37 +1109,23 @@ class MailThread(models.AbstractModel): reply_match = False if reply_match: - compat_mode = False msg_references = tools.mail_header_msgid_re.findall(thread_references) mail_messages = MailMessage.sudo().search([('message_id', 'in', msg_references)], limit=1) - # message is a reply to an existing thread (6.1 compatibility) - # do not match forwarded emails from another OpenERP system (thread_id collision!) - if not mail_messages and local_hostname == reply_hostname and reply_thread_id and reply_model in self.env: - mail_messages = MailMessage.search([ - ('message_id', '=', False), - ('model', '=', reply_model), - ('res_id', '=', reply_thread_id)]) - compat_mode = True - if mail_messages: model, thread_id = mail_messages.model, mail_messages.res_id if not reply_private: # TDE note: not sure why private mode as no alias search, copying existing behavior dest_aliases = Alias.search([('alias_name', 'in', rcpt_tos_localparts)], limit=1) - # TDE Note: compat mode = without context key, why ? because route = self.message_route_verify( message, message_dict, (model, thread_id, custom_values, self._uid, dest_aliases), update_author=True, assert_model=reply_private, create_fallback=True, allow_private=reply_private, drop_alias=True) if route: - # TDE Note: compat mode: parent is invalid for a compat-reply - # message_dict.pop('parent_id', None) - # TDE note: add compat mode for compat mode in debug _logger.info( - 'Routing mail from %s to %s with Message-Id %s%s: direct reply to msg: model: %s, thread_id: %s, custom_values: %s, uid: %s', - email_from, email_to, message_id, compat_mode and ' (compat mode)' or '', model, thread_id, custom_values, self._uid) + 'Routing mail from %s to %s with Message-Id %s: direct reply to msg: model: %s, thread_id: %s, custom_values: %s, uid: %s', + email_from, email_to, message_id, model, thread_id, custom_values, self._uid) return [route] elif route is False: return [] diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py index 707e316bca5..b729a105b98 100644 --- a/addons/mail/tests/test_mail_gateway.py +++ b/addons/mail/tests/test_mail_gateway.py @@ -580,25 +580,29 @@ class TestMailgateway(TestMail): msg_id='<1198923581.41972151344608186802.JavaMail.diff1@agrolait.com>') # when 6.1 messages are present, compat mode is available + # Odoo 10 update: compat mode has been removed and should not work anymore self.fake_email.write({'message_id': False}) # Do: compat mode accepts partial-matching emails - frog_groups = self.format_and_process( + self.assertRaises( + ValueError, + self.format_and_process, MAIL_TEMPLATE, email_from='other5@gmail.com', msg_id='<1.2.JavaMail.new@agrolait.com>', to='noone@example.com>', subject='spam', extra='In-Reply-To: <12321321-openerp-%d-mail.channel@%s>' % (self.group_public.id, socket.gethostname())) # 3''. 6.1 compat mode should not work if hostname does not match! + # Odoo 10 update: compat mode has been removed and should not work anymore and does not depend from hostname self.assertRaises(ValueError, self.format_and_process, MAIL_TEMPLATE, email_from='other5@gmail.com', msg_id='<1.3.JavaMail.new@agrolait.com>', to='noone@example.com>', subject='spam', - extra='In-Reply-To: <12321321-openerp-%d-mail.channel@neighbor.com>' % frog_groups.id) + extra='In-Reply-To: <12321321-openerp-%d-mail.channel@neighbor.com>' % self.group_public.id) # Test created messages - self.assertEqual(len(self.group_public.message_ids), 2, 'message_process: group should contain 6 messages') - self.assertEqual(len(self.group_public.message_ids[0].child_ids), 0, 'message_process: msg1 should not have children') + self.assertEqual(len(self.group_public.message_ids), 1) + self.assertEqual(len(self.group_public.message_ids[0].child_ids), 0) @mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models') def test_message_process_duplicate(self):