[FIX] mail: fixed ancestor search in message_post.
bzr revid: tde@openerp.com-20121025154215-ue4tpe3cua7491no
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user