تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
7375 أدوات العرض

..Im not sure if it is a bug or I'm just wrong in my code but it is not working for me.. All i want to do is when my state is 'final' the group will be readonly, but it is not working

* attrs="{'readonly': [('state','=','final')]}"*

and when i use this code:

* states="{'final':[('readonly',True)]}"*

instead of being readonly , the group becomes invisible..

Can anyone know to fix this?? Thanks in advance :D

الصورة الرمزية
إهمال
أفضل إجابة

Please try this one, redefine the state field in .py file with

readonly=False, states={'final':[('readonly',True)]},

thanks.

الصورة الرمزية
إهمال
الكاتب

There is an error Error: Unknown field state in domain [["state","in",["final"]]]

Add <field name="state" invisible="1"> in the view where you are using above code you describe.

الكاتب

Thanks for help.. I got it now.. but I'm wondering can i do this in .xml, because if I use this in .py I need to put readonly=False, states={'final':[('readonly',True)]}, in all of my fields and it is to many.. Technically when my state becomes final the whole form should be in readonly.. Thanks

You can do it in xml but here also you need to add attrs like: attrs="{'readonly':[('state','=','final')]}" in all fields you want to make readonly.

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 23
2025
0
فبراير 25
834
1
أكتوبر 24
4731
2
أكتوبر 24
3764
2
يونيو 24
2607