跳至内容
菜单
此问题已终结
1 回复
3499 查看
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
形象
丢弃
最佳答案

Not sure what your asking? Everything seems to be working fine from the terminal outputs 


形象
丢弃
相关帖文 回复 查看 活动
1
8月 24
4425
2
5月 22
10079
2
10月 20
5343
0
3月 20
20065
0
3月 15
3204