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

This codes is under the tree view.

<field name="price_subtotal" attrs="{'invisible': [('discount', '=', False)]}"/>

It isn't working, besides it only hides the value not the entire column.​

But if I used invisible="1", it works but i need a condition like the codes above.

Any help would be a big thing.


Thanks in advance.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You cannot hide a column in a normal tree view based on a condition(or field) in the same record like you have mentioned here.
The reason is that, tree view consists of multiple records. For some of the records this condition can be true and for some other records the condition can be false and hence you cannot build a tree view and define a particular columns visibility by satisfying conditions of  all distinct records.

However, you can define the visibility of a column for an inline tree view based on a condition on the parent record (eg: sale order line inline tree view in the sale order form)please see the below line.

<field name="price_subtotal" attrs="{'column_invisible': [('parent.discount', '=',  False)]}"/>
in the above line 'discount' is a field in the sale.order model and parent here is sale.order record.
The field named 'price_subtotal' which exists in the inline sale order line tree view can be hidden like this.

อวตาร
ละทิ้ง
ผู้เขียน

Thank you :)

Dear Anagh Jose,

Hope you are good :)

The same logic i applied to my code.

I am getting the below error.

Error: Unknown field parent.price_fixed in domain ["|",["parent.price_fixed","=",true],["locked","=",true]]

price_fixed is a field in my parent.

Tried on Odoo 16 and still works! Thank you so much!

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

Hi try this..

<field name="price_subtotal" attrs="{'column_invisible': (['discount', '=', False])}"/>

อวตาร
ละทิ้ง
ผู้เขียน

Thanks im going to try this one.