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

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
فبراير 25
979
2
فبراير 25
8560
1
أكتوبر 22
3829
3
يناير 19
7159
8
فبراير 17
8371