Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
4 Vastaukset
1087 Näkymät

I want the status record to be uneditable if state = active, done

Avatar
Hylkää
Paras vastaus

Hi,

In Odoo 17, to make a field (like status) read-only when the record’s state is either "active" or "done" You can achieve this using the 'readonly' attribute in the XML view, or by using Python logic with @api.depends and readonly=True on the field.


XML


<field name="status" readonly="state in ['active', 'done']"/>


Hope it helps

Avatar
Hylkää
Paras vastaus

is this you need for particular users or all users  ( not to edit record - only view)

Avatar
Hylkää
Tekijä Paras vastaus

i want to all fields in record to be uneditable

Avatar
Hylkää
Paras vastaus

Use the following code in your XML:

field name="state" readonly="state in ['active', 'done']"

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
elok. 25
157
1
elok. 25
585
1
elok. 25
489
4
heinäk. 25
1823
1
heinäk. 25
1039