콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
8856 화면

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
1619
3
7월 25
3264
1
5월 25
1409
1
5월 25
1658
4
5월 25
2820