Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
8327 Tampilan

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.

Avatar
Buang
Penulis

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

Jawaban Terbai

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

add

attrs="{'readonly':[('state' , '!=', 'draft')]}"
Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Agu 20
5380
1
Sep 18
9673
2
Mei 21
4350
1
Nov 19
3932
1
Mar 15
5112