Saturday, March 6, 2021

report color from user in odoo

 


In this blog we will explain how read report color from user in odoo . so let us make an example 


First : we have to define char field that will contain the color rbg as bellow

color = fields.Char(string="Color")

Second : create the view for this field as bellow 

<field name="color" widget="colorpicker"/>

or
<field name="color" widget="color"/>

after that the view will look like bellow 


 

Third : we can read our color in the report template as bellow

background-color:<t t-esc="color"/>!important; // to make it as back groud color for some element 

color:<t t-esc="color"/>!important; // to make it as text color

...

Eg : say we want to add it as back ground color for td in a table so we can do it as bellow

&lt;td style="width:100px;font-size:14px; border: 1px solid black;padding-top:2px; padding-bottom:2px;background-color:<t t-esc="color"/>!important; font-size: 14px; text-align:center;font-weight:bold;"
      <span t-esc="field_name"/>

&lt;/td &gt;



I used this with odoo 11 , and it worked :)

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...