Try this function:- I write this function to get the messages for my own purpose, you just make the code as your needs,
def inbox_tree_view(self, cr, uid, ids, context):
project_obj=self.pool.get('project.project')
msg_obj=self.pool.get('mail.message')
data=self.browse(cr,uid,ids[0])
matter_name=data.name
message_ids = msg_obj.search(cr, uid, [])
domain_id_list=[]
for message_id in message_ids:
matter_name_messahe=msg_obj.browse(cr,uid,message_id).parent_id.record_name
if matter_name==matter_name_messahe:
domain_id_list.append(message_id)
print'domain_id_list-----------',domain_id_list
domain = [('id','in', domain_id_list)]
res_id = ids and ids[0] or False
print"ppppppppppppppppppp", res_id
return {
'name': _('Inbox Messages'),
'domain': domain,
'res_model': 'mail.message',
'type': 'ir.actions.act_window',
'view_id': False,
'view_mode': 'tree,form',
'view_type': 'form',
'limit': 80,
'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id)
}
@Axel Mendoza:- Thanks axel, I am familiar with how to add button in our form view, but i am not familiar with how to redirect the view, if you have any example of similar cases please give a chance to make it happen, Thanks , Logicious
let me update the previos answer
@Axel: thanks Axel , i got one error "unread_count " doesn't defined in your system, and also i tried to remove that one, then again the error arise parsing opt/odoo/odoo somthing similar to this.