Calling methods using JSON-RPC
In this recipe, we will learn how to invoke a custom method of the model through JSON-RPC. We will change the status of the room by calling the make_available()
method.
Getting ready
We will create the Python program to call make_available
on 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 create, write, and update a room’s information through RPC:
- Add the
jsonrpc_method.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 method (see last recipe for more)
if user_id: # Create the room record in draft state payload = get_json_payload("object", "execute_kw", ...