import xmlrpclib
# ... define HOST, PORT, DB, USER, PASS
url = 'http://%s:%d/xmlrpc/common' % (HOST,PORT)
sock = xmlrpclib.ServerProxy(url)
uid = sock.login(DB,USER,PASS)
print"Logged in as %s (uid:%d)" % (USER,uid)
# Create a new
ideaurl = 'http://%s:%d/xmlrpc/object' % (HOST,PORT)
sock = xmlrpclib.ServerProxy(url)
args = { 'name' : 'Another idea', 'description' : 'This is another idea of mine', 'inventor_id': uid,}
idea_id = sock.execute(DB,uid,PASS,'idea.idea','create',args
注:
xmlrpclib
这个模块还挺难装的,我就直接使用docker来执行了,这个docker 镜像中带有相关的安装包xcgd/odoo:7.0
odoo8及以上的版本推荐使用OdooRPC
https://pythonhosted.org/OdooRPC/#supported-odoo-server-versions