如何在odoo 9版本

时间:2017-09-06 14:18:11

标签: openerp xml-rpc odoo-9

我需要简单的示例(模块)如何使用odoo XML-RPC。

除odoo网络文档外,有没有人有例子。

TNX

1 个答案:

答案 0 :(得分:2)

以下是xml RPC的示例,希望它能为您提供帮助。

import xmlrpclib

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

# odoo Common login Service proxy object 
sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)

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

partner = {
   'name': 'Fabien Pinckaers',
   'lang': 'fr_FR',
}
#calling remote ORM create method to create a record 
partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)