Odoo Help

0

How to Customize UserMenu on upper right corner

By
Giezel Esteves
on 8/26/16, 10:36 PM 520 views

I want to add another menu

Documentation

Support

About

Preferences

New_menu


What should I do?

0
Tyndare
On 4/27/17, 6:11 AM

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>



0

Shameem iWesabe

--Shameem iWesabe--
880
| 5 3 5
الخبر, Saudi Arabia
--Shameem iWesabe--

Activities     :    Youtube

                           Stackoverflow 

Experience

           iWesabe                                  ◉

           Axon Communications        ❍

           Cybrosys Technologies        ❍


Shameem iWesabe
On 8/27/16, 12:42 AM

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>

 

How to call form in menu?

Giezel Esteves
on 8/27/16, 2:57 AM

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: {

}});

});

});

Shameem iWesabe
on 8/27/16, 4:11 AM

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

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

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

var _t = core._t;

Shameem iWesabe
on 8/27/16, 4:12 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 8/26/16, 10:36 PM
Seen: 520 times
Last updated: 4/27/17, 6:11 AM