Community mailing list archives

community@mail.odoo.com

Re: how to create user using rpc calls

by
redCOR AG, robert rottermann
- 06/25/2016 04:13:28
thanks Nhomar,
On 24.06.2016 09:07, Nhomar Hernandez wrote:

On Fri, Jun 24, 2016 at 12:23 AM, robert rottermann <robert@redcor.ch> wrote:
It is for odoorpc I would like to get a sample how to create a user

http://pythonhosted.org/OdooRPC/ref_models.html

You can set Model and then use normally a create (as if you were inside Odoo).

Model.create(dict)

Where Model is a res.users (as in the link)
not that easy:
here my script:

#!bin/python
# -*- encoding: utf-8 -*-
import odoorpc
odoo = odoorpc.ODOO('localhost', port=8069)
odoo.login('afbstest', 'admin', 'admin')
User = odoo.env['res.users']
User.create({'name':'hans', 'is_company' : False})

# -----------------------------------------
this is the result:

robert@chrissy:~/projects/afbs$ bin/python scripts/rpc_user.py
Traceback (most recent call last):
  File "scripts/rpc_user.py", line 9, in <module>
    User.create({'name':'hans', 'is_company' : False})
  File "/home/robert/projects/afbs/python/local/lib/python2.7/site-packages/odoorpc/models.py", line 74, in rpc_method
    cls._name, method, args, kwargs)
  File "/home/robert/projects/afbs/python/local/lib/python2.7/site-packages/odoorpc/odoo.py", line 469, in execute_kw
    'args': args_to_send})
  File "/home/robert/projects/afbs/python/local/lib/python2.7/site-packages/odoorpc/odoo.py", line 268, in json
    data['error'])
odoorpc.error.RPCError: You cannot create a new user from here.
 To create new user please go to configuration panel.
69
Go to the configuration panel
# -----------------------------------------

so still in search of a sample
thanks
robert


--
Nhomar Hernandez
CEO Vauxoo.
Twitter: @nhomar
Odoo Gold Partner
Skype: nhomar00 (Envia mail previo no lo superviso siempre).
Móvil Venezuela:
+58 4144110269
Móvil México:
+52 1 4773933942

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe