Skip to Content
Menu
This question has been flagged
1 Reply
5048 Views

i want to change the color and size text of an field inside the form view depending on the state , in know there is a possiblity to do so in tree view ,but how we can do the same in the form view ?

Avatar
Discard

hi, did you find any solution for this?

This Odoo app allows users to dynamically change the background and text color of any integer field based on a threshold value. The app introduces a customizable widget that automatically adjusts the visual representation of integer fields, allowing users to define their own colors for values below and above the threshold. Whether for financial figures, performance metrics, or other numeric values, users can easily tailor the display according to their preferences.
https://apps.odoo.com/apps/modules/17.0/mh_integer_field_color_widget

Best Answer

Hi,
You can change the color and other css attributes of a field on the form view by using ‘style’ attribute inside fields. And if you want to show the colors or other attributes based on state you can use invisible attribute for the fields as like mentioned below.

<field name="test_field" style="background-color:red;font-size:60px;color:yellow;" attrs="{'invisible': [('state', '=', 'draft')]}"/>


<field name="test_field" style="background-color:red;font-size:60px;color:yellow;" attrs="{'invisible': [('state', '=', 'sale')]}"/>


Regards

Avatar
Discard