问题
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