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

hi ,

How to make readonly button based on condition?

I have two Button

  • Button 1

  • Button 2

 and my condition is if database filed text is "po" then allow Button 1 and filed text "os" then Button 2.

How to apply condition on button based on Database field.

อวตาร
ละทิ้ง

hi Temur,

I already did this step attrs="{'readonly': [('field_name','=','po')]}".

it's not working dear.

ผู้เขียน คำตอบที่ดีที่สุด

it's not work attrs="{'readonly': [('field_name','=','po')]}" or

attrs="{'readonly': [('field_name','=','so')]}".

My button code line is

<button name="button1" states="approve" string="Button 1" type="object" attrs="{'readonly': [('field_name','=','po')]}" icon="gtk-ok" /> 

I am using openerp v5.

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

Best to make button invisible rather than readonly. It will save space on your view and look more user friendly. 

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

add to "Button 2" in xml:

attrs="{'readonly': [('field_name','=','po')]}" 


similar for "Button 1"


อวตาร
ละทิ้ง