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

 I have created one field in my module and i dont want other user write ,create and edit .

How to acheive this

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

Try like this it may help you,
Add an extra field in the view, ie,

in Xml,

<field name="check_field" invisible="1" />
<field name="new_field" attrs="{'readonly': [('check_field', '!=', True)]}" />

in py,
check_field = fields.Boolean('Check', compute='get_user')


@api.multi  

@api.depends('new_field')   

def get_user(self):
        if SUPERUSER_ID == self._uid:
            self.check_user = True    

       else:
            self.check_user = False





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

Write two views for this model.One for the administrative user and other for the read only group.

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

Find administrative id from res_users model, after
<field name="name_field" attrs="{'readonly': [('<user_id>', '!=', <administrative id>)]}" />

Ảnh đại diện
Huỷ bỏ

<field name="name_field" attrs="{'readonly': [('<user_id>', '!=', 1)]}" />

it will help you..

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 24
6120
3
thg 8 24
6977
4
thg 7 24
41310
5
thg 4 23
99138
3
thg 11 22
4388