콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

By default background color of lines(rows) is white. I would like to change background color of line depends on value in field.

I should realize it in odoo online. 

I know how to set text color in field, using decorators. But I don't know how to change background color.

아바타
취소
작성자

I have this xml

<data>
<xpath expr="//field[@name='id']" position="replace">
<field name="x_desc" optional="hide"/>
<field name="x_ics_number" optional="show" decoration-bf="x_ics_number == '12639'" decoration-success="x_ics_number == '12637'" decoration-warning="x_ics_number == '12641'" decoration-danger="x_ics_number == '12642'"/>
<field name="x_date_in" optional="show"/>
<field name="x_studio_shipped_date" optional="show"/>
<field name="x_oem" optional="show"/>
<field name="x_serial_number" optional="show"/>
<field optional="show" name="x_studio_x_uid"/>
<field name="x_technician" optional="show"/>
<field name="x_rt_number" optional="show"/>
<field name="x_purchase_number" optional="hide"/>
</xpath>
</data>

I know how to change color and style of symbols using decorations. But how can I change background color in odoo online?

베스트 답변

People, read the question. The guy asks for the BACKGROUND colour, not the FONT colour...


Anyhow, you can do that by using this addon:

https://odoo-community.org/shop/colorize-field-in-tree-views-2814#attr=939917

Works like a charm (and on 17!)

아바타
취소
작성자 베스트 답변

Thank you

But in this video, they change color of text, not background color

아바타
취소
베스트 답변
 <tree string="Maintenance" decoration-warning="status == 'en_cours'"
decoration-success="status == 'realise'"
decoration-info="status == 'verifie'">

i  want to color the rows with these colors, and it's not working. can u help me 

아바타
취소
베스트 답변

Hi,

In Odoo, the <tree> element with the decoration-type attribute is used to apply decorations to a tree view based on a specific field value. The decoration-type attribute allows you to specify a condition under which the decoration should be applied.


syntax as follows,


<tree decoration-type="field=='value'">


For example,


<record id="student_student_view_tree" model="ir.ui.view">

<field name="name">student.student.view.tree</field>

<field name="model">student.student</field>

   <field name="arch" type="xml">

       <tree string="Marks" decoration-success="state == 'excellent'"

             decoration-info="state == 'good'"

             decoration-danger="state == 'fail'"

             decoration-warning="state == 'average'">

           <field name="name"/>

           <field name="age"/>

           <field name="grade"/>

           <field name='state'/>

       </tree>

   </field>

</record>

       


For more details, refer to the blog:

https://www.cybrosys.com/blog/tree-view-decoration-attributes-in-odoo-17

Hope it helps,


아바타
취소
베스트 답변

Hi,
You can refer to this video:  How To Give Color For Tree View Records In Odoo

Sample: 
tree decoration-danger="state=='error'" decoration-muted="state=='sent'"

from the above code, decoration-danger will show red color when the value of state is error and decoration-muted will show grey color when the state is sent.

Similarly you have decoration-success, decoration-warning etc


Thanks 

아바타
취소
관련 게시물 답글 화면 활동
1
2월 22
8966
3
4월 24
2400
0
12월 19
5175
2
5월 18
3724
2
3월 15
8054