Calling methods through XML-RPC
With Odoo, the RPC API is not limited to CRUD operations; you can also invoke business methods. In this recipe, we will call the make_available
method to change the book's state.
Getting ready
We will create the Python program to call make_available
on the library.book
model. Make sure that you have installed the my_library
module and that the server is running on http://localhost:8069
.
How to do it...
Perform the following steps to create, write, and update a book's information through RPC:
- Add the
books_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:
from xmlrpc import client 
server_url = 'http://localhost:8069' db_name = 'book-db-14' username = 'admin' password = 'admin' 
common = client.ServerProxy('%s/xmlrpc/2/common' %     server_url...