This question has been flagged
5 Replies
9070 Views

I want to add another menu

Documentation

Support

About

Preferences

New_menu


What should I do?

Avatar
Discard
Best Answer

If this could help, here is an addon for Odoo 9 that modify the UserMenu to make the Support link configurable:

https://github.com/lachouettecoop/chouette-odoo/tree/master/addons/user_menu_chouette

The first thing it does is defining a qweb template to replace the UserMenu definition:

(this static/src/xml/base.xml file is to be added in the 'qweb' section of your __openerp__.py file)

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
  <!-- replace UserMenu dropdown-menu defined in addons/web/static/src/xml/base.xml -->
  <t t-extend="UserMenu" >
    <t t-jquery="ul.dropdown-menu" t-operation="inner">
      <li><a href="#" data-menu="documentation">Documentation</a></li>
      ...
      <li><a href="#" data-menu="new_menu">New Menu</a></li>
    </t>
  </t>
</templates>


Then we have a Javascript file to react to the "new_menu" data-menu entry we added:

(file named static/src/js/menu.js)

odoo.define('your_module.new_menu', function (require) {
"use strict";
var UserMenu = require('web.UserMenu');
// Modify behaviour of addons/web/static/src/js/widgets/user_menu.js
UserMenu.include({
    on_menu_new_menu: function () {
        // your new menu action
    }
});
});


And finaly we should includes this Javascript in the web page:

(the next file is to be added to the 'data' section of your __openerp__.py file)

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- extend template addons/web/views/webclient_templates.xml to include our javascript file -->
        <template id="assets_backend" name="your_module assets" inherit_id="web.assets_backend">
          <xpath expr="." position="inside">
            <script type="text/javascript" src="/your_module/static/src/js/menu.js"></script>
          </xpath>
        </template>
    </data>
</openerp>



Avatar
Discard
Best Answer

Hi Giezel , do it in odoo9

Step 1: Create an xml file for qweb

Your_Module/static/xml/q_template.xml

Step 2: Add in __openerp__.py

'qweb': ['static/xml/q_template.xml'],

Step 3:  Open q_template.xml and write

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="UserMenu">
  <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <img class="oe_topbar_avatar" t-att-data-default-src="_s + '/web/static/src/img/user_menu_avatar.png'"/>
        <span class="oe_topbar_name"/>
        <b class="caret"></b>
    </a>
    <ul class="dropdown-menu">
        <li><a href="#" data-menu="documentation">Documentation</a></li>
        <li><a href="#" data-menu="support">Support</a></li>
        <li><a href="#" data-menu="about">About</a></li>
        <li class="divider"/>
        <li><a href="#" data-menu="settings">Preferences</a></li>
<li><a>New_Menu</a></li>
        <li><a href="#" data-menu="account">My Odoo.com account</a></li>
        <li><a href="#" data-menu="logout">Log out</a></li>
    </ul>
  </li>
</t>
</templates>

 

Avatar
Discard
Author

How to call form in menu?

Try it

xml:

<li id="new_menu_id"><a>New_Menu</a></li>

js:

Example

$(document).ready(function(parent,action){

$('#new_menu_id').click(function(){

var action_manager = new ActionManager(action)

action_manager.do_action({

name: _t('Some thing'),

type: 'ir.actions.act_window',

res_model: 'res.users',

view_mode: 'form',

view_type: 'form',

views: [[false, 'form']],

target: 'new',

context: {

}});

});

});

add following before $(document).ready(function(parent,action)

var ActionManager = require('web.ActionManager');

var core = require('web.core');

var _t = core._t;