跳至内容
菜单
此问题已终结
3 回复
10387 查看

have created a custom menu for the sale order in my Odoo-12 website which is working properly.I just wanted to add the filter on displaying this menu only when the user is logged in.

Here is my code:

<odoo>
  <data noupdate="0">
    <record id="portal_sale_order_menu"model="website.menu">
      <field name="name">Sale Orders</field>
      <field name="url">/my/orders</field>
      <field name="sequence"type="int">1</field>
    </record>
  </data>
</odoo>

Can anyone help me out in this, I have referred many things but seems none of them have worked for me.

Any help is really appreciated.

Thanks!

形象
丢弃
编写者

Hi Pouya Malekinejad,

Working of it seems fine by my method, I just want to hide or make invisible util and unless the user is logged in.

编写者 最佳答案
<odoo>
  <data>
    <template id="custom_sign_in" customize_show="True" inherit_id="website.layout" name="Custom Sign In">
      <xpath expr="//ul[@id='top_menu']" position="replace">
        <ul class="nav navbar-nav ml-auto text-right" id="top_menu">
          <li class="nav-item" t-if="website.user_id != user_id">
            <a class="nav-link" role="menuitem" t-attf-href="/my/orders">
              <span>Sale Order</span>
            </a>
          </li>
          <li class="nav-item divider"></li>
          <li class="nav-item dropdown" t-if="website.user_id != user_id">
            <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
              <b>
                <span t-esc="user_id.name"/>
              </b>
            </a>
            <div class="dropdown-menu js_usermenu" role="menu">
              <a href="/my/home" role="menuitem" class="dropdown-item">My Account</a>
              <a id="o_logout" class="dropdown-item" role="menuitem" href="/web/session/logout?redirect=/">Logout</a>
            </div>
          </li>
          <li class="nav-item" t-if="website.user_id == user_id">
            <a class="nav-link" href="/web/login">
              <b>Sign in</b>
            </a>
          </li>
        </ul>
      </xpath>
    </template>
  </data>
</odoo>
形象
丢弃
最佳答案

I'm not sure about showing, but for working, you can set it in your controller:

 
@http.route('/my/order', type='http', auth="user" # for requiring authentication
            website=True)
def my_order_menu(self, **post): 
return request.render('your_module_name.template')
 
形象
丢弃
相关帖文 回复 查看 活动
5
5月 19
8180
6
11月 18
8583
2
7月 25
6203
1
5月 25
10383
1
4月 24
3725