Odoo Help

Welcome!

This community 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.

0

Is it possible to bind a window action to a first level menu in the sidebar?

By
Eduardo BP
on 5/2/15, 8:18 AM 473 views

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.

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.

Eduardo BP
on 5/2/15, 12:13 PM

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

Jérémy Kersten (jke)
on 5/2/15, 6:14 PM

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

Eduardo BP
on 5/3/15, 7:56 AM
1

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 5/2/15, 11:23 AM

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>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 5/2/15, 8:18 AM
Seen: 473 times
Last updated: 5/3/15, 7:56 AM