import xmlrpclib from pprint import pprint uid=1 #用户名admin所对应的id号 pwd="admin" #admin对应的密码 dbname="demo" tcp_port="8069" sock=xmlrpclib.ServerProxy("http://127.0.0.1:%s/xmlrpc/object" % tcp_port) model="hr.employee.category" ##要运行哪个类中的函数? method="read" ##要运行的函数 ##def read (self, cr, uid, ids, fields=None, context=None) #函数签名 ids=[1,2,3] ##参数一, fields=['name','complete_name','parent_id', 'child_ids'] ##参数二 result = sock.execute(dbname, uid, pwd, model,method , ids, fields ) print "\n==== %s of %s ====" % (model, method) pprint(result) |
params = params[3:] ##加在这一行下面 from pprint import pformat ##这一行最后加在文件顶部 if ( params[0][0:2] =='op.' or params[0][1:3] =='op.'): #最关心的模块 s=method+'!'+pformat(params[0])+pformat(params[1:],depth=9) elif ( params[1] =='get_needaction_data'): #最不关心的调用 s=method+'!'+pformat(params[0])+pformat(params[1:],depth=1) else : #其他模块 s=method+'!'+pformat(params[0])+pformat(params[1:],depth=3) |
for k, v in value.items(): write("\n") if type(k) is IntType: ##添加此行和下一行 k = "%d" % k ##将diction的键值由数字转为字符 if type(k) is not StringType: if unicode and type(k) is UnicodeType: k = k.encode(self.encoding) else: raise TypeError, "dictionary key must be string" |
欢迎光临 Odoo中文网|Odoo实施培训 (http://www.chinaodoo.net/) | Powered by Discuz! X3.2 |