preloader

Building REST Integrations on Top of Odoo

Advertisement space

Integrating Odoo with external systems is not a configuration exercise — it is an engineering discipline. Whether you are syncing a Shopify storefront, connecting a 3PL warehouse, or exporting invoices to an accounting platform, the decisions you make in the first week will define how much pain you absorb in production for the next three years.

Choosing Your Protocol

Odoo ships with JSON-RPC as its primary external interface. It handles the full CRUD surface of every installed model, requires no server customisation, and respects Odoo’s access control layer without extra work. For most read-heavy integrations it is the right default.

The case for a custom REST controller arises when you need a domain-specific endpoint that aggregates logic across models or supports a system that cannot speak JSON-RPC. Custom controllers give you full control over the request and response shape, but they compete for the same worker pool as interactive users — keep them lightweight.

Message queues belong in a third category. When integrating with a 3PL that processes fulfillment events asynchronously or an e-commerce platform that fires webhooks at unpredictable rates, a broker decouples the systems, absorbs spikes, survives Odoo restarts, and lets you replay failed events without touching production data.

Authentication and Session Management

JSON-RPC authentication in Odoo is session-based. The session expires, and if your integration runs as a daemon, it will hit an authentication failure at some point. If you have not designed for it, that failure will be silent and the data loss will surface days later.

The reliable pattern is automatic re-authentication on failure and a dedicated service account with the minimum access rights needed. For custom REST endpoints, API key authentication is cleaner than session cookies for machine-to-machine traffic. Odoo’s built-in API key support, available from version 14, gives you a stateless credential that does not expire on server restart.

Designing for Failure and Odoo Restarts

Odoo restarts. Deployments happen, workers crash, and the database enters maintenance mode during migrations. Any integration that assumes continuous availability will fail in production.

The patterns that work are:

  • Outbox tables inside Odoo — write to a local staging area before attempting external delivery; a background job drains the outbox and retries on failure.
  • Idempotent consumers — every record pushed externally carries a stable Odoo identifier so duplicate deliveries are detected and discarded.
  • Exponential backoff with a dead-letter destination — events that fail beyond a threshold go to a dead-letter queue for human review, not silent discard.

Defining the Integration Contract

Before writing code, answer four questions in writing: what data flows, in which direction, on what trigger, and what happens on error. A good contract covers the canonical field-level mapping between Odoo’s model and the external schema, the trigger model (event-driven, scheduled, or on-demand), error ownership, and the backward compatibility policy.

For e-commerce sync, the contract must address inventory reservation conflicts and order cancellations in flight. For accounting exports, it must define period cutoffs and the reconciliation procedure when a record is rejected upstream.

Real-World Integration Patterns

Common scenarios each carry their own failure modes:

  • E-commerce sync — concurrent stock updates from multiple channels and cancellations arriving after warehouse fulfillment has started.
  • 3PL connections — fulfillment confirmations are almost always asynchronous; do not close a picking until you receive explicit confirmation from the 3PL.
  • Accounting exports — most systems reject records with missing fields silently; validate before submission rather than debugging rejections.
  • POS integrations — high-frequency, low-latency events require batching; never block the POS transaction waiting for Odoo to confirm receipt.

Building integrations on Odoo is ultimately about respecting system boundaries — giving each system ownership of its own state, communicating through well-defined contracts, and treating every network call as a potential failure. The engineers who do this well are not the ones who know the most API endpoints. They are the ones who have thought through what happens when things go wrong and designed for it from the start.

You May Also Like