'Transfer the list of the mail thread messages from an model to another
:param id : the old res_id of the mail.message
:param new_res_id : the new res_id of the mail.message
:param new_model : the name of the new model of the mail.message
Example :   my_lead.message_change_thread(my_project_issue)
will transfer the context of the thread of my_lead to my_project_issue'

@api.multi
def message_change_thread(self, new_thread):

    self.ensure_one()
    subtype_comment = self.env.ref('mail.mt_comment')
    MailMessage = self.env['mail.message']
    msg_comment = MailMessage.search([('model', '=', self._name), ('res_id', '=', self.id), ('subtype_id', '=', subtype_comment.id)])
    msg_not_comment = MailMessage.search([('model', '=', self._name), ('res_id', '=', self.id), ('subtype_id', '!=', subtype_comment.id)])
    msg_comment.write({'res_id': new_thread.id, 'model': new_thread._name})
    msg_not_comment.write({'res_id': new_thread.id, 'model': new_thread._name, 'subtype_id': None})
    return True
