[FIX] mail: fixed ancestor search in message_post.

bzr revid: tde@openerp.com-20121025154215-ue4tpe3cua7491no
This commit is contained in:
Thibault Delavallée
2012-10-25 17:42:15 +02:00
parent 0f0fc9cd97
commit 3e36e6c88f
2 changed files with 11 additions and 5 deletions
+6 -5
View File
@@ -679,11 +679,12 @@ class mail_thread(osv.AbstractModel):
# we want to set a parent: force to set the parent_id to the oldest ancestor, to avoid having more than 1 level of thread
elif parent_id:
message_ids = mail_message.search(cr, SUPERUSER_ID, [('id', '=', parent_id), ('parent_id', '!=', False)], context=context)
_counter, _counter_max = 0, 200
while (message_ids and (_counter <= _counter_max)):
parent_id = message_ids[0]
message_ids = mail_message.search(cr, SUPERUSER_ID, [('id', '=', parent_id), ('parent_id', '!=', False)], context=context)
_counter += 1
if message_ids:
_counter, _counter_max = 0, 200
message = mail_message.browse(cr, SUPERUSER_ID, message_ids[0], context=context)
while (message.parent_id and (_counter <= _counter_max)):
message = message.parent_id
parent_id = message.id
values = kwargs
values.update({
+5
View File
@@ -436,6 +436,11 @@ class test_mail(TestMailMockups):
self.assertIn((attach.name, attach.datas.decode('base64')), _attachments,
'mail.message attachment name / data incorrect')
# 3. Reply to the last message, check that its parent will be the first message
msg_id3 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Test', parent_id=msg_id2)
message = self.mail_message.browse(cr, uid, msg_id3)
self.assertEqual(message.parent_id.id, msg_id, 'message_post did not flatten the thread structure')
def test_25_message_compose_wizard(self):
""" Tests designed for the mail.compose.message wizard. """
cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs