Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3183 Visualizzazioni

Hi, I dont know how to change a group of a user by coding (a function will be called by a button?)

I explored that "self.env.user.has_group('group_name')" will be return True, how can I do with that?

Avatar
Abbandona
Autore

Thank you so much

Risposta migliore

Hi Nedera,

You can add or remove users to/from a group as follows

group = ...your target group...
users = [...a list of users...]

#Add
group.write({'users': [(4, user.id) for user in users]})

#Remove

group.write({'users': [(3, user.id) for user in users]})

For more information see this answer: https://www.odoo.com/forum/help-1/security-60-and-4-in-openerp-89686

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
ott 22
3261
1
lug 20
4105
1
giu 25
1885
3
lug 25
3488
1
mag 25
1616