Steps to Create Odoo Menu and Manage New Odoo User Menu

HARSHAD
March 14, 2023

It is easy to create an Odoo menu and actions in Odoo with a common approach.

The profile photo you use for Odoo can be found at the top right corner of your page. Users can access information, settings, shortcuts, support, etc., from the user menu that appears when they click on the image.

odoo user menu

The next step in building and administering an Odoo 16-user menu is to look at how to do it.

Here is a menu where you can enable developer mode.

After constructing the module for it, we need to add the supplied value to the Registries. These are crucial for extensibility. After being registered, It uses the object across the website. As part of its JavaScript framework, Odoo supports several features that query the registry (fields, views, client action, services, etc). Registries are key/value maps that are ordered.

Categories of Registry:

  • Effect Registry–An accessible database of all effects.
  • Formatter Register–A set of functions for formatting values.
  • Parser Registry–The parsing of values with functions.
  • Main Components Registry–Components for your web client at the top level
  • Service Registry – Displaying all the list of information on the right side of the nav bar.
  • User Menu Registry–Storing all menu items in the user menu registry.

To add a new user menu, we must expand the user menu registry (category: user menu items) in order to store all the items that appear in the user menu when it is opened.

A user menu item can be defined by using functions that take as an argument the environment, and then output the following data as an object:

  • Description: Menu item Callback.
  • Text: Making a choice and dialing.
  • href: a> element’s value can be placed using the ref property.
  • Hide: Objects to be buried.
  • Order: The dropdowns item’s position in relation to another item in the list

You can Create there is a file in the static/src/js folder.

odoo16 user

Put the bellow code in the js file.

import { registry } from "@web/core/registry";
import { preferencesItem } from "@web/webclient/user_menu/user_menu_items";
import { routeToUrl } from "@web/core/browser/router_service";
import { browser } from "@web/core/browser/browser";
const usersMenuRegistry = registry.category("user_menuitems");
function debugItems(env) {
const URL = $.param.query string(window.location.href, 'debug=1');
return {
type: "item",
id: "debug",
description: env._t("Activate developer mode"),
href: URL,
callback: () => {
browser.open(URL, "_self");
},
sequence: 50,
};                                                                             
}
registry.category("user_menuitems").add("debug", debugItems)

DOWNLOAD ERP

An Odoo module can be automatically converted:

/** @odoo-module **/. Import the method or class. After importing, we need to add a function to the site. After opening a template, UserMenu adds an element with a particular value to the object.

window. location.href: returns the current page’s href (URL).

'assets:{
   'web.assets_backend':[
       '/user_menu/static/src/js/user_menu.js',
   ],
},


When we created the JavaScript, we must add this in the __manifest__.py file in the assets. In the user menu (top right of the navigation bar), there is an option to activate developer mode. As soon as you click on the “Activate Developer Mode” menu, you can see that developer mode has been enabled. In the user menu registry, you can see all menu items that are displayed when you open the user menu (the navbar element with the username). In the user menu (top right of the navigation bar), there is an option to activate developer mode.

creating odoo menu for odoo16As soon as you click on the “Activate Developer Mode” menu, you can see that developer mode has been enabled. In the user menu registry, you can see all menu items that are displayed when you open the user menu (the nav bar element with the username).

Request Your Free Quote

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *