odoo8 xmlrpc 授权登录不了
-
import xmlrpclib url = 'http://127.0.0.1:8067' db = '1221_v8' username = 'admin' password = "admin@123" 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
如何解决?
-
@萧云飞
加了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.