Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
1124 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

i want to all fields in record to be uneditable

Awatar
Odrzuć
Najlepsza odpowiedź

Use the following code in your XML:

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
sie 25
155
0
sie 25
272
1
sie 25
677
1
sie 25
522
4
lip 25
1883