In Odoo 15, learn how to create and manage a new user menu.

Odooprovides a universal method for defining new user menus and associated actions. Odoo is now more practical and simpler to use as a result.

Your profile photo appears in the top right corner of the page when you enter Odoo. The user menu, which appears when you click on the image, offers drop-down options like documentation, settings, shortcuts, support, etc.

Let’s examine how to build a brand-new user menu for turning on developer mode.

To achieve this, the required value must be added to the appropriate Registries. They play a significant role in UI extensibility. The remainder of the web client can use the object after it has been registered.

An (ordered) key/value map is a registry. These are the primary places for web client extensions. When an object (field, view, client action, service, etc.) has to be defined, many of the capabilities offered by the Odoo JavaScript framework look to the registry.

Many types of registries

  • Effect Registry:A database of all effects that are accessible.
  • Formatter Register:Value formatting functions
  • Main Components Registry:Your web client’s top-level components
  • Parser Registry:Value Parsing Functions
  • Systray Registry:Information shown on the navbar’s right side.

The services that need to be activated are all listed in the service registry.

All of the menu items are stored in the Usermenu Registry.

We must expand the User menu registry to add a new user menu in order to do so.

All of the menu items shown when the user menu is opened are stored in the User Menu Registry (category: user menuitems).

Additionally, user menu items are defined by the use of functions that take the environment as an argument and output an object containing the data listed below:

The text of a menu item

Callback:To make a call when a selection is made

href:Use the href attribute to place the item’s value in the a> element.

Hide:To cover up the thing

Order:Establishes where the item stands in relation to other dropdown items.

Make a js file and place it in the static/src/js directory.

Automatic conversion to an Odoo module: /** @odoo-module **/.

Import the class or method.

We must add a function to the Web after importing.

After opening a template, UserMenu adds a new element with a particular value to the object.

window.location.href: return the href (URL) of the current page.

We must include this in the __manifest .py file in the assets after developing the javascript.

Activate the developer mode is a menu item that appears on the user menu when the module has been installed (top right of navigation bar).

Now select “Activate Developer Mode” from the menu. Developer mode is on, as you can see.

All menu items displayed when the user menu is opened are stored in the user menu registry (the navbar element with the username, on the top right).

Hire Dedicated Developers

Reach new heights with WanBuffer’s offshore engineering team. Our team of over 50 highly skilled and dedicated full-stack software engineers have the expertise and experience to tackle your key technology challenges, improve efficiency and reduce expenses. Let us help you drive your business forward today.

Schedule Meeting