Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3 Antwoorden
9204 Weergaven

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

How to acheive this

Avatar
Annuleer
Beste antwoord

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
Annuleer
Beste antwoord

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

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer

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

it will help you..

Gerelateerde posts Antwoorden Weergaven Activiteit
1
dec. 24
6092
3
aug. 24
6935
4
jul. 24
41263
5
apr. 23
99065
3
nov. 22
4355