Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
1073 มุมมอง

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']"

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ส.ค. 25
129
1
ส.ค. 25
570
Change position chatter แก้ไขแล้ว
1
ส.ค. 25
482
4
ก.ค. 25
1818
1
ก.ค. 25
1035