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

I received the answer of this question and the suggested solution worked with me. I think the reason because that there is a fields dictionary in the res dictionary. 

Now, as my last comment there, I needed to change the readonly property of the button 'Split' to 'True' by adding the following loop in the fields_view_get method:

nodes = doc.xpath("//button[@string='Split']")
for node in nodes:
    node.set('readonly','1')

I traced the code and the last line was traversed, but the button on the screen was still active.

Any help is appreciated.


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

Hi,

You can achieve as like below.

doc = etree.fromstring(res['arch']) 
nodes = doc.xpath("//buttons")
for node in nodes:
    if node.attrib['string'] == 'Split':
        node.attrib['readonly'] = '1'
        node.attrib['invisible']='1'
        setup_modifiers(node, {})

res['arch'] = etree.tostring(doc)

I hope it will help you.

Thanks.

Ảnh đại diện
Huỷ bỏ
Tác giả

thx for help, this has worked.

How can i set form view read only for some records or i have to make form view reaonly for those record where a field value is set to False?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 24
14264
2
thg 3 18
5073
0
thg 1 18
3189
1
thg 12 17
7605
2
thg 2 24
25639