Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
13687 มุมมอง

The actual question is facing error in API integration odoo-v12 :

code:

import xmlrpc.client
import logging

url, db = 'localhost:8070', 'lab12'
username, password = 'admin', 'admin'
logging.info("url {} , db {}".format(url, db))
common = xmlrpc.client.ServerProxy('{}/xmlrpc.client/2/common'.format(url))
common.version()
Error:

raise OSError("unsupported XML-RPC protocol")
OSError: unsupported XML-RPC protocol

Any idea !!!! How to resolve the error.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Ramkumar,

Your endpoint configurations are wrong. In V11 & V12 they're no longer under /xmlrpc.client/2/common but under /xmlrpc/2/common
Here's a working example:

from xmlrpc import client as xmlrpclib
url = 'http://127.0.0.1:12000'
db = 'your_database'
username = 'admin'
password = 'admin'

common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))

uid = common.login(db, username, password)
result = models.execute(db, uid, password, 'res.partner', 'search_read', [['id', '=', 1]])
number_of_customers = models.execute(db, uid, password, 'res.partner', 'search_count', [])
print('Number of customers: ' + str(number_of_customers))
print('result: ' + str(result[0].get('name')))


Regards,

Yenthe

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks, It worked perfectly for v11 but for v12 it throws protocol error.

Error:

xmlrpc.client.ProtocolError: <ProtocolError for localhost:8071/xmlrpc/2/common: 404 NOT FOUND>
อวตาร
ละทิ้ง
ผู้เขียน

odoo-server-12.0-conf file needs a change the error resolved:

server_wide_modules = None

Related Posts ตอบกลับ มุมมอง กิจกรรม
[Odoo12] Check current model in python แก้ไขแล้ว
2
ก.พ. 20
12246
1
ก.ค. 19
4436
2
พ.ค. 22
10879
2
พ.ย. 19
4278
2
ก.ค. 23
3162