A Complete Guide to Using XML-RPC in Odoo for External Integrations

Odoo is a powerful and flexible ERP system used by businesses worldwide. In many real-world scenarios, organizations need to connect external applications—such as websites, mobile apps, or third-party platforms—with their Odoo instance.

This is where XML-RPC plays a crucial role.

XML-RPC enables external systems to communicate with Odoo remotely and perform operations like creating, reading, updating, and deleting records—without direct access to the database.

What is XML-RPC 

XML-RPC (Extensible Markup Language – Remote Procedure Call) is a protocol that allows different applications to communicate over the internet using HTTP and XML.

Using XML-RPC, an external application can:

  • Authenticate with Odoo
  • Fetch records
  • Create new records
  • Update existing records
  • Delete records
  • Execute model methods

This makes XML-RPC an excellent choice for integrating Odoo with external systems.

Why Use XML-RPC in Odoo?

XML-RPC is commonly used in scenarios such as:

  • Integrating eCommerce websites with Odoo
  • Synchronizing mobile applications
  • Connecting third-party accounting systems
  • Automating data imports from external platforms

👉 Example:

An eCommerce website can automatically create a Sales Order in Odoo whenever a customer places an order online.

XML-RPC Endpoints in Odoo

Odoo provides two primary XML-RPC endpoints:

EndpointPurpose
/xmlrpc/2/commonAuthentication
/xmlrpc/2/objectAccess models & execute methods

These endpoints act as entry points for secure communication with the Odoo database.


Step 1: Authenticate with Odoo

Before performing any operation, you must authenticate the user.

import xmlrpc.client


url = "http://localhost:8069"

db = "odoo_db"

username = "admin"

password = "admin"


common = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/common")


uid = common.authenticate(db, username, password, {})

print(uid)

If successful, Odoo returns a user ID (uid), which is required for all subsequent operations.

Step 2: Connect to Odoo Models

Once authenticated, connect to the object endpoint:

models = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/object")

This allows you to interact with Odoo models and call their methods remotely.

Step 3: Fetch Records from Odoo

You can retrieve data using the search_read method:

partners = models.execute_kw(

db, uid, password,

'res.partner',

'search_read',

[[['is_company', '=', True]]],

{'fields': ['name', 'email'], 'limit': 5}

)


print(partners)

This example fetches the first five company contacts from Odoo.

Step 4: Create Records in Odoo

To create a new record:

partner_id = models.execute_kw(

db, uid, password,

'res.partner',

'create',

[{

'name': 'John Doe',

'email': 'john@example.com'

}]

)


print(partner_id)

This creates a new contact in Odoo and returns its ID.

Step 5: Update Records

To update an existing record:

models.execute_kw(

db, uid, password,

'res.partner',

'write',

[[partner_id], {'email': 'newemail@example.com'}]

)

This updates the email address of the created contact.

Step 6: Delete Records

To delete a record:

models.execute_kw(

db, uid, password,

'res.partner',

'unlink',

[[partner_id]]

)

⚠️ Use this operation carefully, as it permanently removes data.

Security Considerations

When working with XML-RPC integrations, always follow best practices:

  • Use strong and secure passwords
  • Always prefer HTTPS over HTTP
  • Apply proper user access rights and permissions
  • Avoid using administrator credentials in production
  • Consider IP restrictions or API gateways for added security

Proper security ensures safe and reliable communication between Odoo and external systems.

XML-RPC vs JSON-RPC

Odoo supports both XML-RPC and JSON-RPC.

FeatureXML-RPCJSON-RPC
Data FormatXMLJSON
PerformanceSlightly slowerFaster
Modern UsageLess commonMore common

👉 While JSON-RPC is preferred for modern applications, XML-RPC remains fully supported and widely used in many integrations.

XML-RPC provides a simple yet powerful way to integrate external applications with Odoo. By leveraging its endpoints, developers can:

  • Authenticate users
  • Retrieve and manipulate data
  • Automate workflows
  • Build seamless integrations

With proper implementation and security practices, XML-RPC becomes a reliable bridge between Odoo and external systems.


Share this post
Tags
Archive
Managed Server Services: Why Businesses Need Proactive Monitoring and Maintenance