Skip to main content

Odoo Integration Guide

ECOSIRE is built on Odoo 19 Enterprise. This guide explains how to connect an existing external Odoo instance to ECOSIRE's API, or how to integrate ECOSIRE data with a third-party Odoo deployment via the XML-RPC or REST API bridges.


Introduction

If you run a standalone Odoo 19 installation (on-premise or cloud) and want to push/pull data to ECOSIRE, you can use:

  1. ECOSIRE REST API — Direct HTTP integration (recommended)
  2. Odoo XML-RPC — Standard Odoo remote procedure call protocol
  3. ECOSIRE Odoo Bridge Module — Install in your Odoo for automated sync

This guide covers all three approaches.


Prerequisites

  • ECOSIRE account with an active API key
  • Odoo 19 instance with admin credentials
  • Python 3.9+ or Node.js 18+ (for code examples)
  • Network access between your Odoo server and api.ecosire.com

Step 1 — Generate an ECOSIRE API Key

  1. Log in to ecosire.com/dashboard.
  2. Go to Settings → API Keys → Generate new key.
  3. Store the key in an environment variable: ECOSIRE_API_KEY=eco_live_...

Step 2 — Set Up Odoo XML-RPC Connection

Test connectivity from your server:

import xmlrpc.client

ODOO_URL = "https://your-odoo.example.com"
DB = "your_database"
USERNAME = "[email protected]"
PASSWORD = "your_password"

common = xmlrpc.client.ServerProxy(f"{ODOO_URL}/xmlrpc/2/common")
uid = common.authenticate(DB, USERNAME, PASSWORD, {})
models = xmlrpc.client.ServerProxy(f"{ODOO_URL}/xmlrpc/2/object")

# Test: list partners
partners = models.execute_kw(DB, uid, PASSWORD, "res.partner", "search_read",
[[]], {"fields": ["name", "email"], "limit": 5})
print(partners)

Step 3 — Sync Contacts (Odoo → ECOSIRE)

import os, requests, xmlrpc.client

ECOSIRE_BASE = "https://api.ecosire.com/api"
HEADERS = {"Authorization": f"Bearer {os.environ['ECOSIRE_API_KEY']}",
"Content-Type": "application/json"}

def sync_contacts(models, db, uid, password, limit=100):
partners = models.execute_kw(db, uid, password, "res.partner", "search_read",
[[["active", "=", True]]], {"fields": ["name", "email", "phone", "is_company"], "limit": limit})

for p in partners:
payload = {
"name": p["name"],
"email": p.get("email") or "",
"phone": p.get("phone") or "",
"type": "company" if p["is_company"] else "person",
}
resp = requests.post(f"{ECOSIRE_BASE}/contacts", json=payload, headers=HEADERS)
if resp.status_code == 409:
print(f" Skipped (duplicate): {p['name']}")
elif resp.ok:
print(f" Synced: {p['name']}")
else:
print(f" Error {resp.status_code} for {p['name']}: {resp.text}")

Step 4 — Sync Products (Odoo → ECOSIRE)

def sync_products(models, db, uid, password):
products = models.execute_kw(db, uid, password, "product.template", "search_read",
[[["active", "=", True], ["type", "in", ["product", "consu"]]]],
{"fields": ["name", "default_code", "list_price", "type"], "limit": 200})

for p in products:
payload = {
"name": p["name"],
"sku": p.get("default_code") or "",
"price": int(p["list_price"] * 100), # Convert to cents
"currency": "usd",
"type": "physical",
}
resp = requests.post(f"{ECOSIRE_BASE}/products", json=payload, headers=HEADERS)
print(f" {'OK' if resp.ok else 'ERR'}: {p['name']}")

Step 5 — Pull ECOSIRE Orders into Odoo

def pull_ecosire_orders(models, db, uid, password):
# Fetch confirmed orders from ECOSIRE
resp = requests.get(
f"{ECOSIRE_BASE}/orders?status=confirmed&limit=100",
headers=HEADERS
)
orders = resp.json()["data"]

for order in orders:
# Find or create partner in Odoo
contact = order["contact"]
partner_ids = models.execute_kw(db, uid, password, "res.partner", "search",
[[["email", "=", contact["email"]]]])

if not partner_ids:
partner_id = models.execute_kw(db, uid, password, "res.partner", "create", [{
"name": contact["name"],
"email": contact["email"],
}])
else:
partner_id = partner_ids[0]

# Create sale order
so_id = models.execute_kw(db, uid, password, "sale.order", "create", [{
"partner_id": partner_id,
"note": f"Imported from ECOSIRE: {order['reference']}",
}])
print(f" Created SO {so_id} for {contact['name']}")

Step 6 — Install the ECOSIRE Bridge Module (Optional)

For automated ongoing sync, install the ECOSIRE Bridge module in your Odoo:

  1. Download ecosire_bridge.zip from your dashboard downloads.
  2. In Odoo, go to Apps → Upload Module and upload the ZIP.
  3. Install ECOSIRE Bridge.
  4. Go to Settings → ECOSIRE → Configuration and enter your API key.
  5. Enable the sync schedules you need (contacts, products, orders — configurable intervals).

The bridge module handles deduplication, conflict resolution, and delta sync automatically.


Step 7 — Verify the Integration

  • Create a contact in Odoo; verify it appears in ECOSIRE Contacts within the scheduled interval (or immediately if using webhooks).
  • Create an order in ECOSIRE; verify it appears in Odoo after the pull job runs.
  • Check sync logs in Odoo → ECOSIRE → Sync Logs for any errors.

Troubleshooting

IssueSolution
Authentication failsConfirm ECOSIRE_API_KEY is set and has not expired
Duplicate records createdEnable "Match by email" in bridge settings
XML-RPC connection refusedCheck Odoo xmlrpc is enabled in odoo.conf
Products missing from syncVerify products are active=True and not archived in Odoo

Next Steps