no changes in menu items after updating this code trying to remove the some of them

160 Views Asked by At

enter image description here highlighted are the submenu item i want to hide in a custom module. here are some changes that i have done on backend side but it does not effect the UI side adding menu in static please click to see

i have added in manifest also here is my manifest file manifest file for module please click to see

here is my js code file where i'm trying to remove the following menu items js code file for removing the menu item please click to see

2

There are 2 best solutions below

18
Kenly On

You can remove the menu items from the registry

Example:

/** @odoo-module **/
import { registry } from "@web/core/registry";
import "@web/webclient/user_menu/user_menu_items";

const user_menuitems = registry.category("user_menuitems");
user_menuitems.remove('documentation');
user_menuitems.remove('support');
user_menuitems.remove('log_out');

Add the js file to the assets entry in the __manifest__.py file:

'assets': {
    'web.assets_backend': [
        "MODULE_NAME/static/src/js/user_menu.js",
     ],
},
0
Muhammad Awais On

The problem was I was using the enterprise edition so because of that the above method was not working So, I have find out the way to hide these menu items by using the JavaScript here is command you can add in JavaScript of your module to hide these menu items you can also verify by directly by using developer mode and in console use the below commands(jQuery) to hide the menu items.

  $("a[data-menu='documentation']").remove();
  $("a[data-menu='account']").remove();
  $("a[data-menu='support']").remove();

Please make sure you document is loaded completely and then after fully loading these commands should be executed to hide these menu items other wise it will not work.