Skip to Content
Menu
This question has been flagged
1 Reply
10661 Views

I am just checking to change the usermenu drop down on the right corner, but could not changed. I followed https://www.odoo.com/forum/help-1/question/how-to-customize-usermenu-on-upper-right-corner-107470, but no success at all. 

Version: odoo11

Avatar
Discard
Best Answer

I think you can use these steps:

Step 1: Create a template file like this:
module_folder/static/src/xml/template.xml
Step 2: Add in your __manifest__.py:
'qweb': ['static/src/xml/template.xml'],
Step 3: Add this code in your template file (template.xml):
NB: If you want just to show "Log Out" menu:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="my_menus_template_id" xml:space="preserve">
    <t t-name="UserMenu.Actions">
        <li class="logout"><a href="#" data-menu="logout">Log out</a></li>
    </t>
</templates>

The basic menus are as follows:
<li><a href="#" data-menu="documentation">Documentation</a></li>
<li><a href="#" data-menu="support">Support</a></li>
<li class="divider"/>
<li><a href="#" data-menu="settings">Preferences</a></li>
<li><a href="#" data-menu="account">My Odoo.com account</a></li>
<li><a href="#" data-menu="logout">Log out</a></li>

Step 4: Add a new menu
    1. Add your menu in template.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates id="my_menus_template_id" xml:space="preserve">
    <t t-name="UserMenu.Actions">
        <li class="logout"><a href="#" data-menu="logout">Log out</a></li>
        <li><a href="#" data-menu="newmenu">New Menu</a></li>
    </t>
</templates>
    2. Create a JS code menu.js like this:  module_folder/static/src/js/menu.js
odoo.define('module_folder.ComplementMenu', function(require) {
"use strict"; var UserMenu = require('web.UserMenu'); var ComplementMenu = UserMenu.include({ _onMenuNewmenu: function () {
        //...Here your code      } }); return ComplementMenu; });
    3. Add your JS file  in your xml view like this module_folder/views/menu_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
  <template id="assets_backend" name="tools assets" inherit_id="web.assets_backend">
    <xpath expr=".">
      <script type="application/javascript" src="/module_folder/static/src/js/menu.js"/>
    </xpath>
  </template>
</odoo>
And in your __manifest__.py add:
data': [
        'views/menu_view.xml', 
],

I hope It will help you.
Avatar
Discard
Related Posts Replies Views Activity
2
Aug 23
1224
1
Jul 23
1269
1
Jul 23
6434
1
Dec 15
2906
0
Mar 15
2441