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

The 'Objective Group' tree belongs to a One2Many field linking the 'Objective Groups' model with the 'Job Plans' model that the view shows. Is there any way to disable this 'Add an Item' option conditionally?

For example on state 'draft' of 'Job Plans' i want this option to appear, but if state changes then the option should disappear.

Thanks in advance.

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

<notebook>

<page string="Objective Group">

<field name="objective_group_ids">

<tree string="Objective Group" create="true" edit="true" delete="true">

<field name="state" invisible="1" default="draft"/>

<field name="check_is_manager" invisible="1"/>

<field name="name" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>

<field name="description" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>

<field name="weight" sum="Total" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>

<field name="rating" readonly="1" attrs="{'invisible': [('state', 'in', ['draft','review'])]}" />

</tree>

</field>

</page>

</notebook>

Câu trả lời hay nhất

you can make read-only one2many field according to the condition.

add

attrs="{'readonly':[('state' , '!=', 'draft')]}"
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 20
5058
1
thg 9 18
9402
2
thg 5 21
4125
1
thg 11 19
3706
1
thg 3 15
4876