Last active
September 7, 2022 11:10
-
-
Save joelhandwell/0733b273d47d1a126070c77100c12a5e to your computer and use it in GitHub Desktop.
Create Odoo User via API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# reference https://www.odoo.com/forum/help-1/question/how-to-create-a-new-user-and-give-him-access-via-api-96337 | |
import xmlrpclib | |
url = "http://localhost:8069" | |
db = "Odoo8TestMac" | |
username = 'admin' | |
password = 'admin' | |
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url)) | |
uid = common.authenticate(db, username, password, {}) | |
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url)) | |
user_id=models.execute_kw(db, uid, password, 'res.users', 'create', | |
[ | |
{ | |
'name':"userAPI9", | |
'login':'[email protected]', | |
'company_ids':[1], | |
'company_id':1, | |
'new_password':'123456', | |
'sel_groups_39_40':40, | |
'sel_groups_9_44_10':10, | |
'sel_groups_29_30':30, | |
'sel_groups_36_37':37, | |
'sel_groups_21_22_23':23, | |
'sel_groups_5':5 | |
} | |
] | |
) | |
# 'sel_groups_9_44_10':10 set the user as Sales Manager | |
# 'sel_groups_29_30':30 set the user as Warehouse Manager | |
# 'sel_groups_36_37:37 set as Manufacturing Manager | |
# 'sel_groups_21_22_23':23 set as Financial Manager | |
# 'sel_groups_39_40':40 set as Purchases Manager | |
# 'sel_groups_5':5 set as Employee. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where and how do you get the sel_group ids