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.
What are menu badges 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 toiInheriting 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.
class your_model(models.Model):
_name = 'your.model'
_inherit = ['ir.needaction_mixin']
state=fields.Selection([('Draft','Draft'),('Submitted','Submitted'),('Approved','Approved')],'State',default='Draft')
@api.model
def _needaction_domain_get(self):
# getting login user groups
user_groups = self.env['get.user.groups'].get_groups_function(self.env.user.login)
# Check if "your_desired_group" is in above groups than show numeric values on the menu, for the state "Submitted"
if set(['your_desired_group']) & set(user_groups):
return [('state', '=', 'Submitted')]
else:
return False
0 comments
Post a Comment