跳至內容
選單
此問題已被標幟
3 回覆
8776 瀏覽次數

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")

頭像
捨棄
作者

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

最佳答案

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

頭像
捨棄

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 !

最佳答案

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>

頭像
捨棄

Thanks a lot!

最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
6月 25
1547
3
7月 25
3216
1
5月 25
1368
1
5月 25
1618
4
5月 25
2770