Xmlrpclib调用自定义方法报错
-
自定义的方法及测试代码如下:
class res_users(osv.osv):
_name = 'res.users'
_inherit = 'res.users'
_columns = {
'vocation_days':fields.float(u'假期总天数',size=44,required=True),
}
def change_vocation_days(self, cr, uid, context=None):
print('ni hao')
res_users()
if name == "main":
import xmlrpclib
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object',allow_none=True)
uid=1
pwd='123'
dbname="aaa"
sock.execute(dbname,uid,pwd,'res.users','change_vocation_days')
报错信息如下:
Traceback (most recent call last):
File "F:\GreenOpenERP-7.0-20131004-231118\openerp\addons\qingjd\qingjd.py", line 47, in <module>
name=sock.execute(dbname,uid,pwd,'res.users','change_vocation_days')
File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1224, in call
return self.__send(self.__name, args)
File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1473, in parse_response
return u.close()
File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault cannot marshal None unless allow_none is enabled: 'Traceback (most recent call last):\n File "F:\GreenOpenERP-7.0-20131004-231118\openerp\service\wsgi_server.py", line 83, in xmlrpc_return\n response = xmlrpclib.dumps((result,), methodresponse=1, allow_none=False, encoding=None)\n File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1085, in dumps\n data = m.dumps(params)\n File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 632, in dumps\n dump(v, write)\n File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 654, in __dump\n f(self, value, write)\n File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 658, in dump_nil\n raise TypeError, "cannot marshal None unless allow_none is enabled"\nTypeError: cannot marshal None unless allow_none is enabled\n'>
请各位不吝赐教。