There's more...

The data fetched through a combination of the search() and read() methods is slightly time-consuming because it will make two calls. search_read is an alternative method for fetching data. You can search and fetch the data in a single call. Here is the alternative way to fetch a book's data with search_read().

It will return the same output as the previous example:

from xmlrpc import client

server_url = 'http://localhost:8069'
db_name = 'test-12'
username = 'admin'
password = 'admin'

common = client.ServerProxy('%s/xmlrpc/2/common' % server_url)
user_id = common.authenticate(db_name, username, password, {})

models = client.ServerProxy('%s/xmlrpc/2/object' % server_url)

if user_id:
search_domain = ['|', ['name', 'ilike', 'odoo'], ['name', 'ilike', 'sql']]
books_ids = models.execute_kw(db_name, user_id, password,
'library.book', 'search_read',
[search_domain, ['name', 'date_release']],
{'limit': 5})
print('Books data:', books_ids)

else:
print('Wrong credentials')
The read and search_read methods will return id fields even if the id field is not requested. Furthermore, for the many2one field, you will get an array made up of the id and display name. For example, the create_uid many2one field will return data like this: [12, 'Parth Gajjar'].
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset