Fetching/searching records using JSON-RPC
In the previous recipe, we saw how you can do authentication through JSON-RPC. In this recipe, we will see how you can fetch the data from the Odoo instance with JSON-RPC.
Getting ready
In this recipe, we will fetch room information with JSON-RPC. 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 room data from the hostel.room
model:
- Add the
jsonrpc_fetch_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:
# place authentication and get_json_payload methods (see first jsonrpc recipe) if user_id:     # search for the room's ids     search_domain = [['name', 'ilike', 'Standard']]     payload = get_json_payload("object", ...