How it works...

In this recipe, we used the Python xmlrpc library to access Odoo instances through XML-RPC. This is a standard Python library and you do not have to install anything else in order to use it.

For authentication, Odoo provides XML-RPC on the /xmlrpc/2/common endpoint. This endpoint is used for meta methods, which do not require authentication. The authentication() method itself is a public method, so it can be called publicly. The Authentication method accepts four arguments—database name, username, password, and user agent environment. The user agent environment is a compulsory argument, but if you do not want to pass the user agent parameter, at least pass the empty dictionary.

When you execute the authenticate() method with all valid arguments, it will make a call to the Odoo server and perform authentication. It will then return the user ID, if the given login ID and password are correct. It will return False if the user is not present or if the password is wrong.

You need to use the authenticate method before accessing any data through RPC. This is because accessing data with the wrong credentials will generate an error. Additionally, the methods used to access data require a user ID instead of a username, so the authenticate method is needed in order to get the ID of the user.

Odoo's online instances (*.odoo.com) use OAuth authentication and so the local password is not set on the instance. To use XML-RPC on these instances, you will need to set the user's password manually from the Settings|Users|Users menu of your instance.
..................Content has been hidden....................

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