Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
9333 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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 !

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 25
1036
2
thg 2 25
8585
1
thg 10 22
3848
3
thg 1 19
7170
8
thg 2 17
8390