Reputation: 475
I want to associate a window action to a menu placed in the left sidebar of Odoo interface. I have a menu named Academy in the top menu bar, and another menu named "Academy Content" in the left sidebar. Here is an image of the interface.
Link to image: Menus Odoo
The "Academy Content" menu doesn't have children. I want to associate a window action (named action_academy_teachers) to the "Academy Content" menu. In the view (view.xml file), I'm defining two menus.
<menuitem sequence="0" id="menu_academy" name="Academy"/>
<menuitem id="menu_academy_content" parent="menu_academy" name="Academy Content" action="action_academy_teachers"/>
The problem is that I can't click on the "Academy Content" menu, it's only a static text, not a link. But if I add a child menu (named "Academy Teachers") to the "Academy Content" menu, and I associate the window action "action_academy_teachers" to "Academy Teachers" menu, this window action is triggered when I click in this menu.
<menuitem sequence="0" id="menu_academy" name="Academy"/>
<menuitem id="menu_academy_content" parent="menu_academy"
name="Academy Content"/>
<menuitem id="menu_academy_content_teachers"
parent="menu_academy_content"
action="action_academy_teachers" name="Academy Teachers"/>
But I want to the "action_academy_teachers" action is triggered when I click on the "Academy Content" menu. I don't want to create another child menu to do this.
window action code:
<record id="action_academy_teachers" model="ir.actions.act_window">
<field name="name">Academy teachers</field>
<field name="res_model">academy.teachers</field>
</record>
Additional information:
Odoo: version 8
OS: Ubuntu 14.04 32 bit
Upvotes: 1
Views: 1428
Reputation: 1108
Normaly it's not working by default, because of the architecture of menus and their structure.
So you need to modify how the menus are displayed, by overriding the "web.menu_secondary" template in "web" module, to add a link to your action.
To achieve that, just add this section to your XML file (or create a new module that depends on 'web' module) :
<template id="menu_secondary" inherit_id="web.menu_secondary">
<div class="oe_secondary_menu_section" position="replace">
<div class="oe_secondary_menu_section">
<span t-if="not menu['action']">
<t t-raw="menu['name']"/>
</span>
<span t-if="menu['action']">
<t t-call="web.menu_link"/>
</span>
</div>
</div>
</template>
Hope this can help!
Upvotes: 1