Skip to Content
Menu
This question has been flagged

Hi Odoo developers,

I'm following the "Building a module" tutorial from Odoo webpage, and I was wondering if I can bind a window action to a first level menu in the sidebar, because I don't want to create a child menu to do this.

<record model="ir.actions.act_window" id="action_openacademy_list_courses">
<field name="name">Cursos</field>
<field name="res_model">openacademy.course</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem id="openacademy_menu_root" name="Open Academy" sequence="1"/>
<menuitem id="openacademy_menu_coursesroot" name="Course Management"
    parent="openacademy_menu_root"
    action="action_openacademy_list_courses"/>

In the above source code, the "Course Management" menu is a first level menu in the sidebar, but although a window action is associated to it, I can't click in this menu to trigger the action. Is it possible to do this?.

Thank you.

Avatar
Discard
Author

Thank you for your answer Jèrèmy, but what changes should I do in the file addons/web/views/webclient_templates.xml?. I located your code starting in line 162 in this file.

I have updated my response... Let us know...

Author

Thank you Jérémy. I appreciate your help. I'll try your solution.

Best Answer

not by default.

Except if you hack the default code here /addons/web/views/webclient_templates.xml

~L160


<div class="oe_secondary_menu_section">
<t t-esc="menu['name']"/>
</div>
<t t-call="web.menu_secondary_submenu"/>



------------------


EDIT: a sample code


It just an idea/method... but you can do all what you want...

In this case, if we have only one children, we do the link on the top menu ...

(Patch here : http://pastesha.re/OjIF?diff)

                                 <t t-foreach="menu['children']" t-as="menu">
+ <t t-set='current_menu' t-value="menu" />
<div class="oe_secondary_menu_section">
- <t t-esc="menu['name']"/>
+ <t t-if="len(current_menu['children']) == 1">
+ <t t-set='menu' t-value="menu['children'][0]" />
+ <t t-call="web.menu_link"/>
+ </t>
+ <t t-if="len(current_menu['children']) != 1">
+ <t t-esc="menu['name']"/>
+ </t>
</div>
<t t-call="web.menu_secondary_submenu"/>
</t>

Avatar
Discard
Related Posts Replies Views Activity
5
Sep 18
8686
3
Mar 24
25161
0
Apr 16
4821
0
Dec 22
1421
1
Nov 22
2661