Search Here

How to Show Notification or Menu Badges in Odoo

In odoo you can add easily menu badges on menu items. Odoo provides a best and very easy way to do that. You can add numeric values next to the menu items through few lines of code.



How to show menu badge in odoo

What are menu badges in odoo


Menu badges are nothing just numeric values (1,2,3..) next to the menu items. The question is why we need these menu badges. The answer is we want to show the user that, following number of task(s)/work has been pending in the following "state" or "workflow".
Read More: How to Create Workflow Process in Odoo

Adding menu badges in odoo


You do not need to do anything more than what's shown in the post. You just need to inheriting from the "mixin" and "defining the method" named "_needaction_domain_get" is all that you need. Odoo will automatically pick it up and display next to all menu items pointing to actions for this particular model. Below are the code snippet, that you just need to copy and paste.

display_notification_menu_badges_odoo.py

Code Description

To use badges in our menu we just need to inherit "ir.needaction_mixin". After inheriting, just define a method named "_needaction_domain_get" this method will return a domain that selects these states value that should be counted towards the number on the badge. In our case it would be "Submitted".

Post a Comment

3 Comments

  1. how to Count for specific menu item?
    I have several menuitem pointing to a same model. I would like to display a needaction count in the menuitem, but so far I was only able to display the same count in all menuitems pointing to my model.

    Is it possible to have a different counts for the same model but different menuitems ? Or at least, is it possible to show the count in only one menuitem and hide notification count in the other?

    ReplyDelete
  2. It does not work odoo 13 community. Pls advise. Thanks in advance

    ReplyDelete
    Replies
    1. Its for odoo8, if you are facing some issue in odoo13 please share your error here.

      Delete