跳至內容
選單
此問題已被標幟
4 回覆
1126 瀏覽次數

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
8月 25
157
0
8月 25
274
1
8月 25
678
1
8月 25
526
4
7月 25
1884