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

I have custom field ,  i want to make it readonly in edit mode if my custom one2many filled with some record . 

here's my xml code

                 <field name="branch_id" attrs="{'readonly': ['|',('penerimaan_line','=',True),('state','!=','draft')]}" required="1"/>

it didn't work ..

 

 

 

 

 

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

Try this: <field name="branch_id" attrs="{'readonly': [('id', '>', 0)]}" required="1"/>.  You need to first define the id field (it's an integer field) and put it in the view.

EDIT:

Sorry I misread your question, it should be: <field name="branch_id" attrs="{'readonly': ['|',('penerimaan_line','&lt;&gt;',[]), ('state','!=','draft')]}" required="1"/>,

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

Thanks ivan , i'll try it

ผู้เขียน

it works , Thanks Ivan

Thanks Ivan.

It's save my time

+1

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

I tried  attrs="{'readonly': [('id', '=', False)]}" and it works for me 

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

Hello Ajeng Shilvie,

try to use this code.

attrs="{'readonly':[('penerimaan_line','!=',False)]}"

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

i already use it , it didn't work

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

Try this one <field name="branch_id" attrs="{'readonly': ['|',('penerimaan_line','&lt;&gt;',False),('state','!=','draft')]}" required="1"/>

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

it didn't work , my fields always readonly even in draft state