Skip to Content
Menu
This question has been flagged
4 Replies
1077 Rodiniai

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

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti
Autorius Best Answer

i want to all fields in record to be uneditable

Portretas
Atmesti
Best Answer

Use the following code in your XML:

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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
0
rugp. 25
140
1
rugp. 25
571
1
rugp. 25
486
4
liep. 25
1819
1
liep. 25
1035