> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Odoo

> Client-mode REST API connector for a curated Odoo External JSON-2 slice: manufacturing orders, stock quants, and maintenance requests

Technical Preview

## Overview

A client-mode connector for a **curated manufacturing / inventory / maintenance** slice of the [Odoo External JSON-2 API](https://www.odoo.com/documentation/19.0/developer/reference/external_api.html) under `https://YOUR_ODOO_HOST/json/2/`:

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| (connectivity) | `GET /web/version` | Unauthenticated; replaces legacy `common.version` |
| search\_read on mrp.production | `POST /json/2/mrp.production/search_read` | Manufacturing app required |
| button\_mark\_done | `POST /json/2/mrp.production/button_mark_done` | Pass `ids` of MOs |
| create on stock.quant adjustments | `POST /json/2/stock.quant/create` | Prefer `context.inventory_mode`; Inventory app |
| create on maintenance.request | `POST /json/2/maintenance.request/create` | Maintenance app required |

`BASE_ADDRESS` is the Odoo host root (no trailing slash). Topics use `erp/odoo/<object>/<verb>`.

> [!NOTE]
>
> This template targets **External JSON-2** (Odoo 19+): `POST /json/2/{model}/{method}` with a Bearer API key. Legacy `/jsonrpc` and `/xmlrpc/2` (`authenticate` + `execute_kw`) are deprecated and scheduled for removal (target Odoo 22). Use JSON-2 for new integrations.

> [!NOTE]
>
> Odoo Online external API access requires a **Custom** plan. Replace `YOUR_ODOO_HOST`, pass a user API key, and set `X-Odoo-Database` when the host serves multiple databases. Prefer Hub secrets for keys. This template has not been verified against a live tenant.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Odoo (External JSON-2 API slice)
# Auth: Bearer {value.json.api_key}
# BASE_ADDRESS: https://YOUR_ODOO_HOST

DEFINE ROUTE OdooRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_ODOO_HOST"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Getwebversion
        WITH SOURCE_TOPIC "erp/odoo/web/version/get"
        WITH DESTINATION_TOPIC "erp/odoo/web/version/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/web/version"
        WITH HEADERS
            ADD "Accept" "application/json"
    ADD EVENT Searchreadmrpproduction
        WITH SOURCE_TOPIC "erp/odoo/mrp-production/search-read"
        WITH DESTINATION_TOPIC "erp/odoo/mrp-production/search-read/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/json/2/mrp.production/search_read"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.api_key}"
            ADD "X-Odoo-Database" "{value.json.database}"
        WITH BODY "{payload}"
    ADD EVENT Buttonmarkdonemrpproduction
        WITH SOURCE_TOPIC "erp/odoo/mrp-production/button-mark-done"
        WITH DESTINATION_TOPIC "erp/odoo/mrp-production/button-mark-done/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/json/2/mrp.production/button_mark_done"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.api_key}"
            ADD "X-Odoo-Database" "{value.json.database}"
        WITH BODY "{payload}"
    ADD EVENT Createstockquant
        WITH SOURCE_TOPIC "erp/odoo/stock-quant/create"
        WITH DESTINATION_TOPIC "erp/odoo/stock-quant/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/json/2/stock.quant/create"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.api_key}"
            ADD "X-Odoo-Database" "{value.json.database}"
        WITH BODY "{payload}"
    ADD EVENT Createmaintenancerequest
        WITH SOURCE_TOPIC "erp/odoo/maintenance-request/create"
        WITH DESTINATION_TOPIC "erp/odoo/maintenance-request/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/json/2/maintenance.request/create"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.api_key}"
            ADD "X-Odoo-Database" "{value.json.database}"
        WITH BODY "{payload}"

```

## Events

| Event | Method | Endpoint | Request topic | Response topic |
| - | - | - | - | - |
| Getwebversion | GET | `/web/version` | `erp/odoo/web/version/get` | `erp/odoo/web/version/get/response` |
| Searchreadmrpproduction | POST | `/json/2/mrp.production/search_read` | `erp/odoo/mrp-production/search-read` | `erp/odoo/mrp-production/search-read/response` |
| Buttonmarkdonemrpproduction | POST | `/json/2/mrp.production/button_mark_done` | `erp/odoo/mrp-production/button-mark-done` | `erp/odoo/mrp-production/button-mark-done/response` |
| Createstockquant | POST | `/json/2/stock.quant/create` | `erp/odoo/stock-quant/create` | `erp/odoo/stock-quant/create/response` |
| Createmaintenancerequest | POST | `/json/2/maintenance.request/create` | `erp/odoo/maintenance-request/create` | `erp/odoo/maintenance-request/create/response` |

## Auth

**Bearer API key (JSON-2) — default in the template:**

1. In Odoo: **Preferences → Account Security → New API Key**. Copy the key once; store it in Hub secrets.
2. Pass the key (and database when required) on the MQTT request payload so headers resolve:

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{"api_key": "YOUR_ODOO_API_KEY", "database": "YOUR_DB"}
```

The connector sends `Authorization: Bearer {value.json.api_key}` and `X-Odoo-Database: {value.json.database}`. Prefer Hub secrets / `GET SECRET`. Never commit real keys.

**Legacy JSON-RPC / XML-RPC (not in this template):** `authenticate(db, login, password)` then `execute_kw(db, uid, password, model, method, args, kwargs)`. Password may be an API key on some deployments. Prefer migrating to JSON-2.

## Example bodies

**search\_read manufacturing orders:**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "context": {"lang": "en_US"},
  "domain": [["state", "=", "confirmed"]],
  "fields": ["name", "product_id", "product_qty", "state", "date_start"],
  "limit": 10
}
```

**button\_mark\_done:**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{"ids": [42]}
```

**stock.quant create (inventory adjustment path):**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "context": {"inventory_mode": true},
  "vals_list": [
    {"product_id": 1, "location_id": 8, "inventory_quantity": 100.0}
  ]
}
```

**maintenance.request create:**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "vals_list": [
    {
      "name": "Line sensor fault",
      "maintenance_type": "corrective",
      "description": "Raised from IIoT alert"
    }
  ]
}
```

Exact `create` argument names follow your Odoo version ORM (`vals_list` vs single `vals`). Discover models/methods on the database `/doc` page when available.

## Deploy

1. Copy `OdooRestApi.lot` (no `ADD METADATA`).
2. Replace `YOUR_ODOO_HOST` in `BASE_ADDRESS`.
3. `-addRoute` on the broker (or Hub deploy).
4. Publish JSON to a request topic; subscribe to the matching `/response` topic.

Hub catalog metadata (icon, description, `STATUS "beta"`) is in `hub-metadata.lot` for Hub / `-listTemplates` only.

## Status

**Blocked** until a live authenticated call succeeds (factory has no Odoo host or API key). Unblock with lab host + database (if needed) + API key, then smoke `POST /json/2/mrp.production/search_read` expecting HTTP 200.

## References

* [External JSON-2 API — Odoo 19.0](https://www.odoo.com/documentation/19.0/developer/reference/external_api.html)
* [External RPC API — Odoo 19.0](https://www.odoo.com/documentation/19.0/developer/reference/external_rpc_api.html)
* [odoo/odoo on GitHub](https://github.com/odoo/odoo)
* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.