How do I hide navbar and root-menu at sidebar from Odoo's web-backend module?

a 夏天 提交于 2020-02-29 10:09:09

问题


I am working on POS Point of sales module, I am opening an Iframe in mobile device to show POS screen but I wanted to hide navbar and sidebar of root-menu items, so normal users can use only POS dashboard.

I have installed POS_Mobile snippet to make it responsive on mobile phones and there I tried writting JS code to hide it.

but it's opening only when I start any POS-session by clicking on resume.

I tried as:

In file pos_mobile_template.xml, adding JQuery as:

 if ($(window).width() < 768) {

            //$("nav.o_main_navbar").hide();

    }else{

       // $("nav.o_main_navbar").show();

    }

but it didn't work as this template is not loaded on POS-dashboard.

This is how I am trying to make it, (now I did it by deleting navbar, by inspecting elements, which is same I wanted to do but don't know where to inherit and write, without affecting other functionality).

This is how actually it is:

also, I tried passing param hide_header=true, but that works only for frontend modules not web-backend module.

How can I inherit base POS module and add my JS code to hide navbar, sidebar in mobile devices only when I open for POS-menu?


回答1:


Create a CSS file, for example: your_module/static/src/css/assets_common.css

In the CSS file write following:

@media only screen and (max-width: 480px) {
    .o_main_navbar {
        display:none;
    }
}

**this media query is just an example, use yours as you need*

Then create an XML file, for example: your_module/views/assets.xml

In there link the CSS file:

    <template id="assets_common" inherit_id="web.assets_common">
        <xpath expr="//link[last()]" position="after">
            <link rel="stylesheet" href="/your_module/static/src/css/assets_common.css"/>
        </xpath>
    </template>

In the manifest file add 'web' as depends.

Now update app list and upgrade. Then you should see the CSS is taking effect for mobile view.



来源:https://stackoverflow.com/questions/60349247/how-do-i-hide-navbar-and-root-menu-at-sidebar-from-odoos-web-backend-module

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