Searching/reading records using XML-RPC
In this recipe, we will see how you can fetch the data from an Odoo instance through RPC. The user can access most data, except data that are restricted by the security access control and record rules. RPC can be used in many situations, such as collecting data for analysis, manipulating a lot of data at once, or fetching data for display in another software/system. There are endless possibilities, and you can use RPCs whenever necessary.
Getting ready
We will create a Python program to fetch the room data from the hostel.room
model. Make sure you have installed the my_hostel
module and that the server is running on http://localhost:8017
.
How to do it...
Perform the following steps to fetch a room’s information through RPC:
- Add the
rooms_data.py
file. You can place this file anywhere you want because the RPC program will work independently. - Add the following code to the file:
from xmlrpc import client # room data...