Odoo Help


how can i create access right for a group with XMLRPC python

on 7/22/14, 11:05 AM 1,019 views

import xmlrpclib

username = 'admin' #the user
pwd = 'admin'      #the password of the user
dbname = 'openerp' #the database

# Get the uid
sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)

#replace localhost with the address of the server
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object'

diki = {'id':1,'name':"myname",'model_id':1,'group_id': 1,'perm_read':0,'perm_write':1,'perm_create':0,'perm_unlink':1}

group = {
  'category_id': 1, # many2one
  'name': 'newgroup14', #simple field
  'implied_ids': [(6,0,[3, 2, 1])], #one2many
  'users' : [(6,0,[1])],
  'menu_access' : [(6,0,[1])], #many2many
  'view_access' : [(6,0,[1])],
  'comment' : 'chopito',
  'model_access' :diki
   } #many2many

#Read partner data



partner_id = sock.execute(dbname, uid, pwd, 'res.groups', 'create', group)


Ben Bernard

--Ben Bernard--
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 7/22/14, 10:11 PM

It is easier to see from ir.model.access model perspective. So, after create that group with your script (no need model_access in group hash), you make access control with script like this

ret = sock.execute(dbname, uid, pwd, 'ir.model.access', 'create', {
                'name': diki['name'],
                'model_id': diki['model_id'],
                'group_id': partner_id,
                'perm_create': diki['perm_create'],
                'perm_read': diki['perm_read'],
                'perm_unlink': diki['perm_unlink'],
                'perm_write': diki['perm_write']
            if ret:
                print 'ACL {} created'.format(diki['name'])

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/22/14, 11:05 AM
Seen: 1019 times
Last updated: 3/16/15, 8:10 AM