コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
9294 ビュー

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
2月 25
977
2
2月 25
8559
1
10月 22
3827
3
1月 19
7158
8
2月 17
8370