Skip to Content
Menu
This question has been flagged
3 Replies
10392 Views

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!

Avatar
Discard
Author

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.

Author Best Answer
<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>
Avatar
Discard
Best Answer

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')
 
Avatar
Discard
Related Posts Replies Views Activity
5
May 19
8182
6
Nov 18
8584
2
Jul 25
6206
1
May 25
10385
1
Apr 24
3741