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

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

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

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

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'>

    请各位不吝赐教。



  • 自定义的方法及测试代码如下:

    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'>

    请各位不吝赐教。


登录后回复
 

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