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

Hello, I am trying to set a readonly attribute to True or False for a field on an xml view if a many2one field has a certain value for that record using the domain.

Example:

     <field name='some_field' attrs=" { 'readonly': [('product_id.active', '=', False )] }" />

The problem is I get an error saying:

     Error: Unknown field product_id.active in domain [["product_id.active","=",False]]  

Is there a way to find what the related value is for a many2one field, and set another fields attributes based on that? Thank you

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

You can create a related ...

rel_prod_active = field.related('product_id','active', string="is_prod_active', type='boolean') and use in domain this related field: [["rel_prod_active","=",False]] ...

Not tested... but it should works !

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

Thank you for your post. I was able to get this to work, but was trying to avoid creating another field on the model. Nonetheless, I will use this because it is easy to implement. Thank you

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 25
1003
2
ก.พ. 25
8566
Domain with inherited field แก้ไขแล้ว
1
ต.ค. 22
3833
How to fill a many2one field in openerp แก้ไขแล้ว
3
ม.ค. 19
7164
8
ก.พ. 17
8376