تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4 الردود
1115 أدوات العرض

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

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

i want to all fields in record to be uneditable

الصورة الرمزية
إهمال
أفضل إجابة

Use the following code in your XML:

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أغسطس 25
130
0
أغسطس 25
217
1
أغسطس 25
660
1
أغسطس 25
518
4
يوليو 25
1867