Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
1089 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhấ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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

i want to all fields in record to be uneditable

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Use the following code in your XML:

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 8 25
157
1
thg 8 25
585
1
thg 8 25
489
4
thg 7 25
1823
1
thg 7 25
1039