How to create a custom template for the website navigation odoo 13

蓝咒 提交于 2020-08-09 07:20:05

问题


How to create a custom odoo walker for the website navbar

Similar to what Wordpress allows to create a html template which them odoo uses to add the menus so I can design the navigation

<nav>
    <div class="logo"></div>
     <ul>
       <!-- odoo menu items---> 
       <!-- formatting---> 
       <!-- <li class="nav-item"><a href="$link"> $name </a></li>---> 
     </ul>
     <div>
       <ul>
          <li><a href="$myaccount_link">$name</a></li>
          <li><a href="$logout_link"> $name</a></li>
       </ul>
     </div>
</nav>

Is there a similar function in odoo

if not how to get all the active menus in odoo in JS

example of a Wordpress walker


回答1:


this is a work around, you can find the code in addons/portal/views/portal_templates.xml.

                <div class="collapse navbar-collapse" id="top_menu_collapse">
                    <!-- FIXME We want menu to open to the right by default (except cases handled in JS) -->
                    <ul class="nav navbar-nav ml-auto text-right" id="top_menu">
                        <li class="nav-item divider" t-ignore="true" t-if="not user_id._is_public()"/>
                        <li class="nav-item dropdown" t-ignore="true" t-if="not user_id._is_public()">
                            <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
                                <b>
                                    <span t-esc="user_id.name[:23] + '...' if user_id.name and len(user_id.name) &gt; 25 else user_id.name"/>
                                </b>
                            </a>
                            <div class="dropdown-menu js_usermenu" role="menu">
                                <a id="o_logout" class="dropdown-item" t-attf-href="/web/session/logout?redirect=/" role="menuitem">Logout</a>
                            </div>
                        </li>
                    </ul>
                </div>

the method _is_public() return True if the "user" is not logged else false



来源:https://stackoverflow.com/questions/62604027/how-to-create-a-custom-template-for-the-website-navigation-odoo-13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!