Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
1445 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor Nejlepší odpověď

i want to all fields in record to be uneditable

Avatar
Zrušit
Nejlepší odpověď

Use the following code in your XML:

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
říj 25
263
2
říj 25
364
1
říj 25
348
1
zář 25
341
1
zář 25
425