Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Inbox in custom module

on 9/9/15, 3:52 AM 709 views

I have a problem that one custom module have on Button it should shows the no of unread messages in inbox, when we click on that its directly go to inbox view of messaging.i don't know how to solve it, if anybody have idea about this problem , please share, or any suggestion also welcome  to solve this problem.



@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

on 9/9/15, 5:28 AM

let me update the previos answer

Axel Mendoza
on 9/10/15, 12:59 AM

@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.

on 9/10/15, 3:39 AM

Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 9/9/15, 4:25 AM

Yes this could be done in a form, like this:

<div class="oe_right oe_button_box" name="buttons">
    <button class="oe_inline oe_stat_button" type="object" name="open_inbox" icon="fa-envelope" context="{'partner_id': partner_id}">
        <field string="Unread" name="unread_count" widget="statinfo"/>

With that code in your form view you will see a button that show the number of unread messages in your inbox using the field unread_count that you need to implement as a function field for return the integer number. Also you need to implement a method open_inbox that returns the action view definition, or you could directly define your button type="action" and the name="%(action_record_id)d"

This code is using ir.actions.client because that is the type of action for the inbox

def open_inbox(self, cr, uid, ids, context=None):
    mod_obj = self.pool.get('ir.model.data')
    act_obj = self.pool.get('ir.actions.client')
    res_id = mod_obj.xmlid_to_res_id(cr, uid, 'mail.action_mail_inbox_feeds', raise_if_not_found=True)
    result = act_obj.read(cr, uid, [res_id], context=context)[0]
    return result
On 9/10/15, 3:43 AM

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):

message_ids = msg_obj.search(cr, uid, [])
for message_id in message_ids:
if matter_name==matter_name_messahe:

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)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)


Asked: 9/9/15, 3:52 AM
Seen: 709 times
Last updated: 12/23/15, 3:03 PM