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

由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

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

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

odoo8 xmlrpc 授权登录不了



  • import xmlrpclib
    
    url = 'http://127.0.0.1:8067'
    db = '1221_v8'
    username = 'admin'
    password = "[email protected]"
    
    common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
    print(common.version())
    uid = common.authenticate(db, username, password, {})
    print(uid)
    

    报错信息:

    2017-12-25 10:09:59,614 26118 ERROR 1221_v8 openerp.http: object unbound
    Traceback (most recent call last):
      File "/home/odoo/odoo-dev/odoo8/odoo8/openerp/http.py", line 115, in dispatch_rpc
        result = dispatch(method, params)
      File "/home/odoo/odoo-dev/odoo8/odoo8/openerp/service/common.py", line 26, in dispatch
        return fn(*params)
      File "/home/odoo/odoo-dev/odoo8/odoo8/openerp/service/common.py", line 38, in exp_authenticate
        return res_users.authenticate(db, login, password, user_agent_env)
      File "/home/odoo/odoo-dev/odoo8/exide/auth_log/auth_log.py", line 28, in authenticate
        'ip': request.httprequest.remote_addr,
      File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 338, in __getattr__
        return getattr(self._get_current_object(), name)
      File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 297, in _get_current_object
        return self.__local()
      File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 132, in _lookup
        raise RuntimeError('object unbound')
    RuntimeError: object unbound
    2017-12-25 10:10:29,585 6016 WARNING exide_v8 openerp.sql_db: Cursor not closed explicitly
    
    

    补充:是因为继承了res.users,并重写了 def authenticate(self, db, login, password, user_agent_env):方法,如下:

        def authenticate(self, db, login, password, user_agent_env):
            uid = super(res_users, self).authenticate(db, login, password, user_agent_env)
            cr = self.pool.cursor()
            if uid:
                r = self.pool.get('auth.log').create(cr, SUPERUSER_ID, {
                    'user_id': uid,
                    'time': fields.datetime.now(),
                    'ip': request.httprequest.remote_addr,
                })
                cr.commit()
            return uid
    

    如何解决?



  • 报错信息提示你,数据库游标没有正常关闭, 你打开了数据库游标,你就要关闭噻,在你return语句前面,关闭游标就可以了



  • @萧云飞
    加了cr.close(),报错同样:

    2017-12-27 03:47:45,506 15161 ERROR 1227_v8 openerp.http: object unbound
    Traceback (most recent call last):
      File "/home/odoo/odoo-dev/odoo8/odoo8/openerp/http.py", line 115, in dispatch_rpc
        result = dispatch(method, params)
      File "/home/odoo/odoo-dev/odoo8/odoo8/openerp/service/common.py", line 26, in dispatch
        return fn(*params)
      File "/home/odoo/odoo-dev/odoo8/odoo8/openerp/service/common.py", line 38, in exp_authenticate
        return res_users.authenticate(db, login, password, user_agent_env)
      File "/home/odoo/odoo-dev/odoo8/exide/module/auth_log/auth_log.py", line 28, in authenticate
        'ip': request.httprequest.remote_addr,
      File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 338, in __getattr__
        return getattr(self._get_current_object(), name)
      File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 297, in _get_current_object
        return self.__local()
      File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 132, in _lookup
        raise RuntimeError('object unbound')
    RuntimeError: object unbound
    2017-12-27 03:47:45,509 15161 WARNING 1227_v8 openerp.sql_db: Cursor not closed explicitly
    Please enable sql debugging to trace the caller.
    


  • @1234567 嗯,刚再仔细看了下,这个cr没有正常关闭,只是其中一个警告,还有一个报错信息,你自定义的anthenticate方法中,字典中'ip': request.httprequest.remote_addr报错,你再检查下试试



  • @萧云飞
    我看见这个错误啦,这个不知道怎么解决呢


Log in to reply