Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4251 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Tác giả

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

Câu trả lời hay nhất

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>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 9 18
9096
3
thg 3 24
25830
0
thg 4 16
5235
0
thg 12 22
1822
1
thg 11 22
3390