Skip to Content

Odoo XML-RPC: Integrate with Python, Node, and Go

Odoo's external interface explained

Odoo's XML-RPC API lets external systems read, create, update, and delete data. Python, JavaScript, Go, PHP, virtually any language with XML-RPC support can communicate with Odoo.

Authentication

Three steps: connect to /xmlrpc/2/common, authenticate with database, username, and password, get a user ID (uid). Then connect to /xmlrpc/2/object with uid and password for all subsequent calls.

CRUD operations

search: find records with domain filters. read: fetch field values. create: create new record. write: update existing. unlink: delete. search_read: combines search and read in one call (more efficient).

Python example

The standard library xmlrpc.client is enough. No external dependency needed. Connect, authenticate, call execute_kw with model name, method, and arguments. Ten lines of code to fetch all customers in city 'Stockholm'.

Domain filters

Odoo domains are lists of tuples: [('city', '=', 'Stockholm'), ('is_company', '=', True)]. Default AND. Use | for OR: ['|', ('city', '=', 'Stockholm'), ('city', '=', 'Göteborg')]. Polish notation, a bit unusual but powerful.

Limitations

XML-RPC is synchronous and not optimized for large volumes. Fetching 10,000 records? Do it with offset and limit in batches of 500. Write operations trigger all Odoo mechanisms (constraints, computed fields, mail sending). That's good for data integrity but can be slow for bulk operations.

Alternatives: JSON-RPC (same functionality, different format) and OdooRPC (Python library wrapping XML-RPC with a nicer interface).

Odoo ORM: Computed Fields and Onchange Methods
Automatic calculation without writing SQL