Skip to Content
Menu
This question has been flagged
3 Replies
9208 Views

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

How to acheive this

Avatar
Discard
Best Answer

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





Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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

Avatar
Discard

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

it will help you..

Related Posts Replies Views Activity
1
Dec 24
6094
3
Aug 24
6949
4
Jul 24
41272
5
Apr 23
99084
3
Nov 22
4359