跳至内容
菜单
此问题已终结
2 回复
8095 查看

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.

形象
丢弃
编写者

<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>

最佳答案

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

add

attrs="{'readonly':[('state' , '!=', 'draft')]}"
形象
丢弃
相关帖文 回复 查看 活动
1
8月 20
5096
1
9月 18
9445
2
5月 21
4157
1
11月 19
3740
1
3月 15
4917