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

when user selects anyother value rather than nil i want to make form readonly so i used this but it is not working if anyone have idea please help me here is my code                 <sheet readonly="state !='nil'">

               <field name="state"/>

python code: state = fields.Selection([

        ('nil', 'Nil'),

        ('open', 'open'),

        ('in_progress', 'In Progress'),

        ('resolved', 'Resolved'),

        ('closed', 'Closed')

    ], string="Status", default="nil")



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
ADD ATTR READONLY TO YOUR XML FILE


<sheet>

    <field name="state"/>

    <field name="fields" attrs="{'readonly': [('state', '!=', 'nil')]}"/>

</sheet>


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

Hi,
You have to add readonly condition to every node/fields in the form, you cannot generically add it to sheet tag.

Either you can apply to all fields directly or using python methods, you can do it.


Thanks

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

yes bro, This worked