如何在Odoo的Web后端模块的边栏中隐藏导航栏和根菜单? [英] How do I hide navbar and root-menu at sidebar from Odoo's web-backend module?

查看:629
本文介绍了如何在Odoo的Web后端模块的边栏中隐藏导航栏和根菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用POS Point of sales module,,我正在移动设备上打开iframe以显示POS屏幕,但是我想隐藏根菜单项的导航栏和侧边栏,因此普通用户只能使用POS仪表板.

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.

我已经安装了POS_Mobile片段以使其在手机上具有响应性,并且我尝试编写JS代码将其隐藏.

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

但是它仅在我单击resume来启动任何POS会话时才打开.

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

我尝试过:

在文件pos_mobile_template.xml中,将JQuery添加为:

In file pos_mobile_template.xml, adding JQuery as:

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

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

    }else{

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

    }

但是它不起作用,因为此模板未加载到POS仪表板上.

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).

实际上是这样的:

此外,我尝试传递参数hide_header=true,但这仅适用于前端模块,而不适用于web-backend模块.

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

仅当我打开POS菜单时,如何才能继承基本POS模块并添加JS代码以隐藏移动设备中的导航栏和侧边栏?

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?

推荐答案

创建CSS文件,例如: your_module/static/src/css/assets_common.css

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

在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*

然后创建一个XML文件,例如: your_module/views/assets.xml

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

在其中链接CSS文件:

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>

清单文件中,根据需要添加"web".

In the manifest file add 'web' as depends.

现在更新应用程序列表并升级.然后,您应该会看到CSS正在针对移动视图生效.

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

这篇关于如何在Odoo的Web后端模块的边栏中隐藏导航栏和根菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆