Odoo Help

Turkesh Patel
On 2/28/15, 5:01 AM

You can set users using this python code. put that in any method and use that method.

res_groups = self.pool['res.groups']

users = self.pool['res.users'].search(cr, uid, [], context) #if you not want to set group to all user then set proper domain instead of []

group_id = self.pool['ir.model.data'].get_object(cr, uid, 'your_module_name',  'salesmen_commission_group')

res_groups.write(cr, uid, [group_id], {'users': [(4, user) for user in users]}, context=context)

Thanks, It's working for me +1

Ankit H Gandhi(AHG)
on 11/2/17, 3:22 AM
Jordan Vrtanoski
On 2/28/15, 3:40 AM

Here is example of adding the admin user to the group you have created trough the XML:

        <record model="res.groups" id="salesmen_commission_group">
            <field name="name">Commission</field>
            <field name="comment">Salesmen Commission Permission Group.</field>
            <field name="category_id" ref="module_category_commission"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>


Gustavo Belduma
On 11/8/18, 4:10 PM


in my case it worked in the following way

def assign_perms(self):
    users_id = [1, 2, 3, 4, 5, .........]
    aux_users = [(4, i) for i in users_id]
    group = self.env['res.groups'].search([('id', '=', self.env.ref('module_name.identifier').id)])
    group.write({'users': aux_users})

Daniel Lopez
On 12/22/17, 4:34 PM

Hi dude,

You can try with this for python

def set_commission_group(self, user_id):
commission_group = self.env.ref('your_module_name.salesmen_commission_group')
commission_group.write({'users': [(4, user_id)]})

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 2/28/15, 2:16 AM
Seen: 9209 times
Last updated: 11/8/18, 4:10 PM