Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
8810 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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 !

Câu trả lời hay nhất

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>

Ảnh đại diện
Huỷ bỏ

Thanks a lot!

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
1589
3
thg 7 25
3239
1
thg 5 25
1384
1
thg 5 25
1630
4
thg 5 25
2791