try:
from xmlrpc import client as xmlrpclib
except ImportError:
import xmlrpclib
url = <insert server URL>
db = <insert database name>
username = 'admin'
password = <insert password for your admin user (default: admin)>
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
print(common.version())
#calling methods
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
uid = common.login(db, username, password)
print(uid)
result = models.execute(db, uid, password, 'res.partner', 'search_read', [['id', '=', 1]])
number_of_customers = models.execute(db, uid, password, 'res.partner', 'search_count', [])
#checking access rights
print(models.execute_kw(db, uid, password, 'sale.order', 'check_access_rights', ['read'], {'raise_exception': False}))
#list records
print(models.execute_kw(db, uid, password, 'sale.order', 'search', [[['partner_id.name', '=', 'Gemini Furniture']]]))
#
# print(models.execute_kw(db, uid, password, 'res.partner', 'search',[[['is_company', '=', True], ['customer', '=', True]]]))
print('Number of customers: ' + str(number_of_customers))
print('result: ' + str(result[0].get('name')))
OUTPUT:
{'server_serie': '13.0', 'server_version_info': [13, 0, 0, 'final', 0, 'e'], 'server_version': '13.0+e', 'protocol_version': 1}
2
True
[30, 28, 33, 32, 31, 29, 16, 14, 13, 12, 10, 8, 7, 4, 27, 26, 25, 24, 23, 22, 21, 9, 15, 11, 17, 34, 35, 18, 36]
Number of customers: 36
result: YourCompany