Python Odoo v13 UID/API的问题
Odoo v13的api有问题。我能够获得服务器信息,但由于某些原因,uid没有被返回Python Odoo v13 UID/API的问题,python,api,odoo,Python,Api,Odoo,Odoo v13的api有问题。我能够获得服务器信息,但由于某些原因,uid没有被返回 import xmlrpc.client url ="localhost:8069" db = "pnv3" username = "test" password = "test" common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url)) print(common.version()) uid = common.authe
import xmlrpc.client
url ="localhost:8069"
db = "pnv3"
username = "test"
password = "test"
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
print(common.version())
uid = common.authenticate(db, username, password, url)
print(uid)
获取此错误
Traceback (most recent call last):
File "C:/Users/Web Content/.PyCharmCE2019.3/config/scratches/scratch.py", line 11, in <module>
uid = common.authenticate(db, username, password, url)
File "C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1452, in __request
verbose=self.__verbose
File "C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1154, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1170, in single_request
return self.parse_response(resp)
File "C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1342, in parse_response
return u.close()
File "C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 656, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 1: 'Traceback (most recent call last):\n File "/odoo/odoo-server/odoo/modules/registry.py", line 59, in __new__\n return cls.registries[db_name]\n File "/odoo/odoo-server/odoo/tools/func.py", line 69, in wrapper\n return func(self, *args, **kwargs)\n File "/odoo/odoo-server/odoo/tools/lru.py", line 44, in __getitem__\n a = self.d[obj].me\nKeyError: \'pnv3\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/odoo/odoo-server/odoo/addons/base/controllers/rpc.py", line 63, in xmlrpc_2\n response = self._xmlrpc(service)\n File "/odoo/odoo-server/odoo/addons/base/controllers/rpc.py", line 43, in _xmlrpc\n result = dispatch_rpc(service, method, params)\n File "/odoo/odoo-server/odoo/http.py", line 138, in dispatch_rpc\n result = dispatch(method, params)\n File "/odoo/odoo-server/odoo/service/common.py", line 61, in dispatch\n return g[exp_method_name](*params)\n File "/odoo/odoo-server/odoo/service/common.py", line 30, in exp_authenticate\n res_users = odoo.registry(db)[\'res.users\']\n File "/odoo/odoo-server/odoo/__init__.py", line 104, in registry\n return modules.registry.Registry(database_name)\n File "/odoo/odoo-server/odoo/modules/registry.py", line 61, in __new__\n return cls.new(db_name)\n File "/odoo/odoo-server/odoo/modules/registry.py", line 73, in new\n registry.init(db_name)\n File "/odoo/odoo-server/odoo/modules/registry.py", line 141, in init\n with closing(self.cursor()) as cr:\n File "/odoo/odoo-server/odoo/modules/registry.py", line 492, in cursor\n return self._db.cursor()\n File "/odoo/odoo-server/odoo/sql_db.py", line 649, in cursor\n return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)\n File "/odoo/odoo-server/odoo/sql_db.py", line 186, in __init__\n self._cnx = pool.borrow(dsn)\n File "/odoo/odoo-server/odoo/sql_db.py", line 532, in _locked\n return fun(self, *args, **kwargs)\n File "/odoo/odoo-server/odoo/sql_db.py", line 600, in borrow\n **connection_info)\n File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 130, in connect\n conn = _connect(dsn, connection_factory=connection_factory, **kwasync)\npsycopg2.OperationalError: FATAL: database "pnv3" does not exist\n\n'>
Process finished with exit cod
回溯(最近一次呼叫最后一次):
文件“C:/Users/Web Content/.PyCharmCE2019.3/config/scratches/scratch.py”,第11行,在
uid=common.authenticate(数据库、用户名、密码、url)
文件“C:\Users\Web Content\AppData\Local\Programs\Python\37\lib\xmlrpc\client.py”,第1112行,在调用中__
返回self.\u发送(self.\u名称,args)
文件“C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py”,第1452行,在请求中
verbose=self.\uuu verbose
请求中的文件“C:\Users\Web Content\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py”,第1154行
返回self.single\u请求(主机、处理程序、请求体、详细)
文件“C:\Users\Web Content\AppData\Local\Programs\Python\37\lib\xmlrpc\client.py”,第1170行,在单个请求中
返回self.parse_响应(resp)
文件“C:\Users\Web Content\AppData\Local\Programs\Python\37\lib\xmlrpc\client.py”,第1342行,在parse\u响应中
返回u.close()
文件“C:\Users\Web Content\AppData\Local\Programs\Python37\lib\xmlrpc\client.py”,第656行,关闭
raise故障(**self.\u堆栈[0])
xmlrpc.client.Fault:
工艺以出口cod结束
一,
数据库确实存在,已三次检查我的密码,不确定此时还需要做什么。Odoo服务器的url应在开头包含协议部分“http://”。奇怪的是你竟然得到了版本信息。这个版本的输出是什么 您还可以将url作为最后一个参数传递给
authenticate
方法,这不是必需的。这仍然不会给出您收到的错误
使用这两个修复程序尝试您的代码,如果有帮助,请报告:
import xmlrpc.client
url ="http://localhost:8069"
db = "pnv3"
username = "test"
password = "test"
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
print(common.version())
uid = common.authenticate(db, username, password, {})
print(uid)
相同的代码在我的机器上工作 Odoo服务器的url应在开头包含协议部分“http://”。奇怪的是你竟然得到了版本信息。这个版本的输出是什么 您还可以将url作为最后一个参数传递给
authenticate
方法,这不是必需的。这仍然不会给出您收到的错误
使用这两个修复程序尝试您的代码,如果有帮助,请报告:
import xmlrpc.client
url ="http://localhost:8069"
db = "pnv3"
username = "test"
password = "test"
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
print(common.version())
uid = common.authenticate(db, username, password, {})
print(uid)
相同的代码在我的机器上工作 请同时显示您的配置“odoo.sh shell”导入odoo.tools。。。。tools.config…检查数据库的所有者,当您转到数据库管理时,是否显示数据库,是否使用odoo UI创建了数据库?请同时显示您的配置“odoo.sh shell”导入odoo.tools。。。。tools.config…检查数据库的所有者,当您转到“数据库管理”时,是否显示数据库,是否使用odoo UI创建了数据库?我不确定原因,但在重新编写代码后,它会工作并返回UID。可能是账单问题?不确定,但是谢谢你!我不确定为什么,但在重新编写代码后,它会工作并返回UID。可能是账单问题?不确定,但是谢谢你!