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

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

How to acheive this

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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





อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง

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

it will help you..

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ธ.ค. 24
6096
3
ส.ค. 24
6952
how to know the odoo master password? แก้ไขแล้ว
4
ก.ค. 24
41285
Default value in form view แก้ไขแล้ว
5
เม.ย. 23
99108
3
พ.ย. 22
4361