Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

Xmlrpclib调用自定义方法报错



  • 自定义的方法及测试代码如下:<br /><br />class res_users(osv.osv):<br />    _name = 'res.users'<br />    _inherit = 'res.users'<br />    _columns = {<br />            'vocation_days':fields.float(u'假期总天数',size=44,required=True),<br />            }<br />    def change_vocation_days(self, cr, uid, context=None):<br />        print('ni hao')<br />    <br />res_users()<br /><br /><br />if name == "main":<br />    import xmlrpclib<br />    sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object',allow_none=True)<br />    uid=1<br />    pwd='123'<br />    dbname="aaa"<br />    sock.execute(dbname,uid,pwd,'res.users','change_vocation_days')<br />  <br /><br /><br />报错信息如下:<br />Traceback (most recent call last):<br />  File "F:\GreenOpenERP-7.0-20131004-231118\openerp\addons\qingjd\qingjd.py", line 47, in <module><br />    name=sock.execute(dbname,uid,pwd,'res.users','change_vocation_days')<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1224, in call<br />    return self.__send(self.__name, args)<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1578, in __request<br />    verbose=self.__verbose<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1264, in request<br />    return self.single_request(host, handler, request_body, verbose)<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1297, in single_request<br />    return self.parse_response(response)<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1473, in parse_response<br />    return u.close()<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 793, in close<br />    raise Fault(**self._stack[0])<br />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'><br /><br />请各位不吝赐教。<br />



  • 自定义的方法及测试代码如下:<br /><br />class res_users(osv.osv):<br />    _name = 'res.users'<br />    _inherit = 'res.users'<br />    _columns = {<br />            'vocation_days':fields.float(u'假期总天数',size=44,required=True),<br />            }<br />    def change_vocation_days(self, cr, uid, context=None):<br />        print('ni hao')<br />    <br />res_users()<br /><br /><br />if name == "main":<br />    import xmlrpclib<br />    sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object',allow_none=True)<br />    uid=1<br />    pwd='123'<br />    dbname="aaa"<br />    sock.execute(dbname,uid,pwd,'res.users','change_vocation_days')<br />  <br /><br /><br />报错信息如下:<br />Traceback (most recent call last):<br />  File "F:\GreenOpenERP-7.0-20131004-231118\openerp\addons\qingjd\qingjd.py", line 47, in <module><br />    name=sock.execute(dbname,uid,pwd,'res.users','change_vocation_days')<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1224, in call<br />    return self.__send(self.__name, args)<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1578, in __request<br />    verbose=self.__verbose<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1264, in request<br />    return self.single_request(host, handler, request_body, verbose)<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1297, in single_request<br />    return self.parse_response(response)<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 1473, in parse_response<br />    return u.close()<br />  File "F:\GreenOpenERP-7.0-20131004-231118\python\lib\xmlrpclib.py", line 793, in close<br />    raise Fault(**self._stack[0])<br />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'><br /><br />请各位不吝赐教。<br />


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待