Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
9198 Vizualizări

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

How to acheive this

Imagine profil
Abandonează
Cel mai bun răspuns

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





Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează

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

it will help you..

Related Posts Răspunsuri Vizualizări Activitate
1
dec. 24
6087
3
aug. 24
6930
4
iul. 24
41255
5
apr. 23
99054
3
nov. 22
4350