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

Is there a way to change whether the field is required or not based on some method or some other field in a different module?

Something that would work both on create and write?



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

Create a related field and hide it in the form view, then write it into the attrs attribute of the view definition:

class my_model(osv.osv):
    _name = 'my.model'
    _columns = {
        # ...
        'other_field': fields.related('other_object_id', 'other_object_field', type='boolean', string='Other Field'),
    }
<field name="my_field" attrs="{'required': [('other_field','=',True)]}"/>
<field name="other_field" invisible="1"/>
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
7968
2
thg 8 22
14937
0
thg 6 22
2230
1
thg 10 19
5528
2
thg 9 19
6473