xml – 如何在OpenERP中展开和折叠菜单?

是否有任何模块可以扩展或折叠OpenERP 7中的侧边栏菜单.

或者我们如何在OpenERP 7中做到这一点.

最佳答案 如果要使用动画折叠它们,可以将这些模板添加到模块中

    <template id="web.menu_secondary">
        <a class="oe_logo" t-att-href="'/web/?debug' if debug else '/web'">
            <span class="oe_logo_edit">Edit Company data</span>
            <img src='/web/binary/company_logo'/>
        </a>
        <div>
            <div>
                <div class="oe_secondary_menus_container">
                    <t t-foreach="menu_data['children']" t-as="menu">
                        <div style="display: none" class="oe_secondary_menu" t-att-data-menu-parent="menu['id']">
                            <t t-foreach="menu['children']" t-as="menu">
                                <div class="oe_secondary_menu_section" style="cursor: pointer;">
                                    <t t-esc="menu['name']"/>
                                </div>
                                <t t-call="web.menu_secondary_submenu"/>
                            </t>
                        </div>
                    </t>
                </div>
            </div>
        </div>
        <div class="oe_footer">
            Powered by <a href="http://www.odoo.com" target="_blank"><span>Odoo</span></a>
        </div>
    </template>

   <template id="web.webclient_bootstrap" name="Webclient Bootstrap">
        <t t-call="web.layout">
            <t t-set="head">
                <t t-call-assets="web.assets_common"/>
                <t t-call-assets="web.assets_backend"/>
                <script type="text/javascript">
                    $(function() {
                        var s = new openerp.init();
                        <t t-if="init">
                            <t t-raw="init"/>
                        </t>
                        <t t-if="not init">
                            var wc = new s.web.WebClient();
                            wc.setElement($(document.body));
                            wc.start();
                        </t>
                    });
                </script>
            </t>

            <nav id="oe_main_menu_navbar" class="navbar navbar-inverse" role="navigation" groups="base.group_user,base.group_portal">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                </div>
                <div class="navbar-collapse collapse" id="oe_main_menu_placeholder">
                    <t t-call="web.menu"/>
                </div>
            </nav>
            <div class="openerp openerp_webclient_container">
                <table class="oe_webclient">
                    <tr>
                        <td class="oe_leftbar" valign="top">
                            <div groups="base.group_user,base.group_portal">
                                <t t-call="web.menu_secondary"/>
                            </div>
                            <script type="text/javascript">
                                $('.oe_secondary_menu_section').click(function() {
                                    $(this).next().slideToggle(500);
                                });
                            </script>
                        </td>
                        <td class="oe_application"/>
                    </tr>
                </table>
            </div>
        </t>
    </template>

如您所见,我在原始模板中添加了一些内容:

光标的样式

<div class="oe_secondary_menu_section" style="cursor: pointer;">
    <t t-esc="menu['name']"/>
</div>

一个jQuery函数

<script type="text/javascript">
    $('.oe_secondary_menu_section').click(function() {
        $(this).next().slideToggle(500);
    });
</script>

*它至少在Odoo v8中运行

点赞