Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
Created June 11, 2015 12:28
Show Gist options
  • Select an option

  • Save wisaruthk/17ee1bc769bad9e27ecb to your computer and use it in GitHub Desktop.

Select an option

Save wisaruthk/17ee1bc769bad9e27ecb to your computer and use it in GitHub Desktop.
import xmlrpclib
url = 'http://localhost:8069'
db = 'kojostudio'
username = 'admin'
password = 'admin'
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
vVersion = common.version()
print(vVersion)
uid = common.authenticate(db,username,password,{})
print(uid)
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
result = models.execute_kw(db, uid, password,
'res.partner', 'check_access_rights',
['read'], {'raise_exception': False})
print(result)
result = models.execute_kw(db, uid, password,
'res.partner', 'search',
[[['is_company', '=', True], ['customer', '=', True]]])
print(result)
ids = models.execute_kw(db, uid, password,
'res.partner', 'search',
[[['is_company', '=', True], ['customer', '=', True]]],
{'limit': 1})
[record] = models.execute_kw(db, uid, password,
'res.partner', 'read', [ids])
# count the number of fields fetched by default
print(len(record))
reads = models.execute_kw(db, uid, password,
'res.partner', 'read',
[ids], {'fields': ['name', 'country_id', 'comment']})
print(reads)
cust = models.execute_kw(db, uid, password,
'res.partner', 'search_read',
[[['is_company', '=', True], ['customer', '=', True]]],
{'fields': ['name', 'country_id', 'comment'], 'limit': 5})
print(cust[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment