Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
8772 Vistas

can anyone help, how to remove or hide user menu items like documentation, preference, my odoo account.... in odoo15

here my code what i try but it's not working:

import { registry } from "@web/core/registry";
registry.category("user_menuitems").remove("documentation")

Avatar
Descartar
Autor

hi midhun m m, my query in 15 version and you shared me link of 14 verison

Thanks for reply :)

Did you get the solution?

Hi bro .. did you get the solution of this?

This efficient tool allows you to remove unnecessary options from the User Account Menu.
https://youtu.be/_scgqjyA9tw

Mejor respuesta

Hi All

For odoo15 remove/add user menu follow this.
JS:

/** @odoo-module **/

import { UserMenu } from "@web/webclient/user_menu/user_menu";
import { patch } from "@web/core/utils/patch";
import { registry } from "@web/core/registry";
import { browser } from "../../core/browser/browser";
const userMenuRegistry = registry.category("user_menuitems");


//For remove menu:

patch(UserMenu.prototype, "Your custom module name.UserMenu", {
setup() {
this._super.apply(this, arguments);
userMenuRegistry.remove("documentation");
},

});


//For add menu:

function documentationItemNew(env) {
const documentationURL = "https://www.odoo.com/documentation/16.0";
return {
type: "item",
id: "documentation",
description: env._t("New Documentation"),
href: documentationURL,
callback: () => {
browser.open(documentationURL, "_blank");
},
sequence: 10,
};
}
registry.category("user_menuitems").add("documentation", documentationItemNew);



Manifest:

'assets': {'web.assets_backend': ['Your custom module name/static/src/js/menu.js']},

Please check this file for more:
/web/static/src/webclient/user_menu/user_menu_items.js

Avatar
Descartar

getting this error:

File "C:\Users\Imran Ahmed\odoo15\server\odoo\tools\js_transpiler.py", line 91, in url_to_module_path
raise ValueError("The js file %r must be in the folder '/static/src' or '/static/lib' or '/static/test'" % url)
ValueError: The js file '/om_hospital/static/core/browser/browser' must be in the folder '/static/src' or '/static/lib' or '/static/test'

Error when render the template
ValueError: The js file '/om_hospital/static/core/browser/browser' must be in the folder '/static/src' or '/static/lib' or '/static/test'
Template: 195
Path: /t/t/t[1]/t[4]
Node: <t t-call-assets="web.assets_backend" t-css="false"/> - - -

This is the js file directory:
C:\Users\Imran Ahmed\odoo15\server\odoo\custom_addons\om_hospital\static\src\js\menu.js
This is what I have in manifest file
'assets': {
'web.assets_backend': [
'om_hospital/static/src/js/menu.js',
],
},

Thank you very much for your answer !

Mejor respuesta

my solution is to replace UserMenu template and display based on id of element

<t t-inherit="web.UserMenu" t-inherit-mode="extension" owl="1">
<xpath expr="//Dropdown[@class='o_user_menu']" position="replace">
<Dropdown class="o_user_menu" t-on-dropdown-item-selected.stop="onDropdownItemSelected">
<t t-set-slot="toggler">
<img class="rounded-circle o_user_avatar" t-att-src="source" alt="User"/> <span class="oe_topbar_name"><t t-esc="user.name"/><t t-if="env.debug" t-esc="' (' + user.db.name + ')'"/></span>
</t>
<t t-foreach="getElements()" t-as="element" t-key="element_index">
<t t-if="!element.hide">
<UserMenuItem
t-if="element.type == 'item' and element.id != 'documentation' and element.id != 'support' and element.id != 'shortcuts' and element.id != 'account'"
payload="{ callback: element.callback, id: element.id }"
href="element.href"
t-esc="element.description"
/>
</t>
</t>
</Dropdown>
</xpath>
</t>

Avatar
Descartar

Thanks a lot!

Mejor respuesta

Hello,

Thank you @Kothiya for your reply. But it seems that it is no longer functional with the latest version of odoo15.
For me, the full menu disappears and odoo is no longer accessible.
What can I do?
Thank you

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
jun 25
1545
3
jul 25
3216
1
may 25
1366
1
may 25
1616
4
may 25
2769