İçereği Atla
Menü
Bu soru işaretlendi
4 Cevaplar
1435 Görünümler

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

Avatar
Vazgeç
En İyi Yanıt

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
Vazgeç
En İyi Yanıt

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

Avatar
Vazgeç
Üretici En İyi Yanıt

i want to all fields in record to be uneditable

Avatar
Vazgeç
En İyi Yanıt

Use the following code in your XML:

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

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
4
Eki 25
255
2
Eki 25
350
1
Eki 25
333
1
Eyl 25
339
1
Eyl 25
421