Add colurs to statusbar in odoo10 - colors

Need to add colour in statusbar in odoo10 which available openerp versions
eg: <field name = 'state' widget=statusbar clickabe= 'True' statubar_colors='{"new": "blue"}'>
How add colours in statusbar in odoo10
Need different color for different states in status bar
For eg: Blue color for draft,green for progress, red for cancel

There is two solution for your requirement:
If you need this behavior for only one Form view, Is simple as this:
just add style tag to beat the css selector generated by Odoo
<style>
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled {
background: yellow;
}
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled::after {
border-left-color: yellow;
}
</style>
...
...
<field name ="state" widget="statusbar">
Here I used the same css selector because it's loaded after Odoo selector it is the one used, notice that my status bare button have .disabled class because it's readonly I think you have to change that clickabe= 'True' means it's not readonly.
if you want to have this for all your model here you need to use css file and add it to assets_backend template, make sure that your selector beat Odoo selector.
<template id="assets_backend" name="backend" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/your_addon_name/static/src/css/your_css_file_name.css"/>
</xpath>
</template>
Now I don't how you want to change the color exactly Here, you need to deal with CSS to select the right element,
for example if you want to make the status bar color blue only when the "new" value is selected, lucky for you
Odoo show the value selected in attribute data-value that doesn't change by translation.
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="new"] {
background: blue;
}
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="new"]::after {
border-left-color: blue;
}
This is in Odoo 11, when I inspected the element, this what I noticed:
status that is selected have class btn-primary the rest have btn-default
readonly have attribute disabled="disabled" and class disabled
And just to show that this work Here is a screen shot of what I have, You may have some side effect, it's when you open some record in popup and this form is still shown in the web page, this will effect the record shown too if it have a status bare widget, because the style tag will be removed when the form view is removed from the web page.
Edits:
Let say your selection has two values : new, valid
This will color new to blue if selected and valid to green fi selected
<style>
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="new"] {
background: blue;
}
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="new"]::after {
border-left-color: blue;
}
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="progress"] {
background: blue;
}
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="progress"]::after {
border-left-color: blue;
}
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="cancel"] {
background: red;
}
.o_form_view .o_form_statusbar > .o_statusbar_status > .o_arrow_button.btn-primary.disabled[data-value="cancel"]::after {
border-left-color: red;
}
</style>
...
...
...
<field name="state" .....>
It's all about selecting the field by data-value Hope you get the idea. and this is easier than having to deal with javascript.

This feature was removed from Odoo a long time ago.
https://github.com/odoo/odoo/issues/5987
https://github.com/odoo/odoo/pull/11199
If you need to add this feature you will have to create a new widget for it.

inherit_id="web.assets_backend"
add style as you need, you can also give style in css

Related

Hide / Remove the DHMLX created watermark (footer) sentence when export pdf or png

Exporting gantt with dhtmlx works fine, but I wondered if there is a way to hide or remove the sentence in watermark (footer):
This document is created with dhtmlx library: http://dhtmlx.com
This sentence is generated when export to pdf or png at the bottom of the doc (even below footer)
The footer (watermark) will be there if you use the export for free.
It's only removed if you buy a paid version of dhtmlxGantt, here are the conditions:
https://dhtmlx.com/docs/products/dhtmlxGantt/export.shtml#:~:text=Free%20Online%20Export%20Service
If you already have the paid version of the component, you can contact dhtmlx sales regarding it.
They remove the watermark by whitelisting the domain where your app is hosted (from where the export is called), so it doesn't happen automatically when you buy the license, you have to request it.
It's also possible to deploy the export locally, the local version doesn't add watermarks. You get the local install with more expensive licenses, or you can buy it separately
I found a way to hide for free the watermark by using the footer using position: absolute. This example will use background red but you can use another color.
Based on the dhtmlx ExporttoPDF we can easily modify the css by using a <style> element, so I did something like this:
HTML FOR EXPORT TO PDF:
<input type="button" onclick='gantt.exportToPDF({
footer:`<style>
#footer-container{ position:relative; }
h4{ width:100%; background: red; position: absolute; top:-10px; }
</style>
<div id="footer-container">
<h4>Bottom Line</h4>
</div>`
})'>
CSS included in HTML above FOR EXPORT TO PDF:
#footer-container{
position:relative;
}
h4{
position: absolute;
top:-10px;
width:100%;
background: red;
}
HTML FOR EXPORT TO PNG:
<input type="button" onclick='gantt.exportToPNG({
footer:`<style>
#footer-container{ position:relative; }
h4{ width:100%; background: red; position: absolute; top:-10px; }
</style>
<div id="footer-container">
<h4>Bottom Line</h4>
</div>`
})'>
CSS included in HTML above FOR EXPORT TO PNG:
#footer-container{
position:relative;
}
h4{
position: absolute;
top:-10px;
width:100%;
background: red;
}
Output:

Creating a new component or widget to switch between Grid and List view in products Page Template

Hello I'm new to Hybris Development,
I want to create a component or a widget to switch between Grid and List View in products page template, in Smartedit there is a productList and a productGrid page types, I want to somehow combine both of the page templates together, whether by adding a new widget or building a whole page template the ground up.
Thanks,
Would you consider doing it with js and css ? You can add some ui element and toggle classes for product-grid section. Then write specific css styles for that class to make it look like list/grid.
CSS:
/* product items - depends on your class names */
.js-list-view .product-item {
width: 100%;
}
.js-list-view .product-item a, .js-list-view .product-item .addtocart {
width: 25%;
display: inline-block;
}
.js-list-view .product-item .details {
width: 50%;
display: inline-block;
}
/* button-switcher */
.list-view-btn-text, .grid-view-btn-text {
display: none;
}
.product-grid-toggle:not(.grid-view-btn) .list-view-btn-text {
display: block;
}
.product-grid-toggle.grid-view-btn .grid-view-btn-text {
display: block;
}
JS
$('.product-grid-toggle').on('click', function () {
/* add js-list-view class to the wrapper of product items */
$('.product-grid').toggleClass('js-list-view');
/* switch text for the button */
$(this).toggleClass('grid-view-btn');
});
html for Switcher - you can create productListSwitcher.jsp and then put it in the impex to the slot you need. Or add the button directly into the the jsp file with product list. Depends on your project structure.
<button class="btn product-grid-toggle grid-view-btn">
<span class="list-view-btn-text">List view</span>
<span class="grid-view-btn-text">Grid view</span>
</button>

hide a span without an id inside a specific ul

I installed eshop plugin in wordpress and I've beed told I should hide the span to hide the title
this is the code
<ul class="eshop rand"><li class="eshop-product-127"><a class="itemref" href="http://localhost/sab/to-40-gr-mix/"><img ilo-full-src="http://localhost/sab/wp-content/uploads/2013/07/DSC_4171-150x150.jpg" src="http://localhost/sab/wp-content/uploads/2013/07/DSC_4171-150x150.jpg" class="attachment-150x150 wp-post-image" alt="DSC_4171" height="150" width="150"></a><span>to 40 GR MIX</span>
I want to hide the span inside that ul with that class (eshop rand)
remember I can't assign an id to that span
thank you
You could use this css class
.eshop.rand span
{
display: none;
}
or
.eshop-product-127 span
{
display: none;
}

sharepoint branding : page width size due to _spBodyOnLoadWrapper() function

i'm trying to make up a different look and feel on my sharepoint site. I try to make my main content's width down to 960px under my form tag in sharepoitn designer. when I refresh the page at the first it renders the main content down to 960px but when the page fishished loading the main content stretches itself to the whole screen's width.
I found out that it's because of the onload script running in body tag. but I caanot remove this script because this work has side effects on page functionality.
the function is _spBodyOnLoadWrapper().
does anyone know this function ? or does anyone know how to come up with this problem ?
UPDATE #1:
My css code is as follows.. I added this class to the main Form on master page:
.mainContent
{
width: 960px;
height:100% !important;
min-height:100% !important;
padding-top: 10px;
margin-left: auto;
margin-right: auto;
direction:rtl;
}
UPDATE #2:
I use v4.master template.
I have taken the ribbon out of the form tag. it's directly after body tag. because I wanted the ribbon to be streched at the top. but when i add this line of code
<body onload="if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">
the mainContent blows up. something at the header streches in the whole width and some panels at bottom remains 960px.
you got me interested so I recreated your issue. By default, the javascript will try to inline the width based on its calculations.
However, what you need is to set the class s4-notsetwidth on a wrapping container.
Here is what i did to fix your issue
Add this to the head
<style type="text/css">
#s4-bodyContainer {
width: 960px;
height:100% !important;
min-height:100% !important;
padding-top: 10px;
margin-left: auto;
margin-right: auto;
}
/* Aligns the Top Bars */
.ms-cui-ribbonTopBars {
width: 960px!important;
margin-left:auto;
margin-right:auto;
}
/* Turns off the border on the bottom of the tabs */
.ms-cui-ribbonTopBars > div {
border-bottom:1px solid transparent !important;
}
</style>
Then locate the s4-workspace (that's the immediate parent of #s4-bodyContainer and add class s4-nosetwidth. That should work for you.
Use these two references to achieve exactly what you want (not sure if you want ribbon aligned or not), Randy Drisgill post and Tom Wilson's post.

ckeditor 3 different body style for full page preview

Is it possible to change body style when entering a full page preview in ckeditor 3. Maybe to set a different body style for full page than when it is not in a full page mode.
The reason for this is using ckeditor when viewing a web page on a larger screen with maximized browser... in that case it is very wide and it is hard to read the content. So I would like to add in body style (but only for full page mode) something like:
...
margin: 5%;
padding: 5%;
border: 1px dotted #666;
...
... that will give more text processor look to the content.
TNX!
When CKEditor is toggled to fullscreen mode it adds "cke_maximized" class to container span.
So you may apply styles for entire container span (body+toolbar) like:
.cke_maximized{
margin: 5%;
padding: 5%;
border: 1px dotted #666;
}
or just for content body:
.cke_maximized iframe{
margin: 5%;
padding: 5%;
border: 1px dotted #666;
}
Those are just examples and you may experiment and choose css selector that is more suitable for you .
UPDATE 1:
Sure, you can use javascript code if it is not enough for your purposes. You can use something like this:
var editor = CKEDITOR.instances.editor1;
editor.on("afterCommandExec", function(e){
if(e.data.name == 'maximize'){
// maximized
if(e.data.command.state == CKEDITOR.TRISTATE_ON){
// add special css class to body(e.editor.document.getBody())
} else {
// minimized
// remove special css from body
}
}
});

Resources