Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
5437 มุมมอง

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 ?

อวตาร
ละทิ้ง

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

คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง