TypeScript SDK for Odoo XML-RPC (/xmlrpc/2/common and /xmlrpc/2/object).
Note This library currently provides a generic Odoo XML-RPC client for common model operations. If you need custom high-level business workflows, build them on top of this client in your own app/service layer.
- XML-RPC authentication (
authenticate) against/xmlrpc/2/common - Generic model methods via
execute_kwon/xmlrpc/2/object - Typed operations:
create,copy,write,read,search,searchCount,unlink - Typed domain operators for Odoo 16-19
- Optional single-company context injection with
companyId - ESM + CJS build output with TypeScript declarations
- Bun
>= 1.0.0(development toolchain) - Odoo
16.0,17.0,18.0, or19.0 - Valid Odoo credentials (user + password/API key)
- Exposes generic model operations only
- Does not include opinionated modules for HR, Sales, Accounting, etc.
- Does not include REST wrappers; transport is XML-RPC
- This SDK is intentionally single-company per client instance
- If
companyIdis set, requests include:context.allowed_company_ids = [companyId]context.company_id = companyId
- For multiple companies, create multiple
OdooClientinstances or run separate queries
- Type definitions include Odoo domain operator differences for 16-19
- Runtime behavior is generic XML-RPC and depends on your Odoo model/method availability
- You need a lightweight typed XML-RPC client
- You want to call Odoo models generically from TypeScript
- You prefer building your own app-specific service layer
- You need built-in domain business APIs (HR workflows, accounting policies, etc.)
- You need non-XML-RPC integration style out of the box
bun add @lixferox/odoo-clientOr with npm:
npm i @lixferox/odoo-clientimport { OdooClient } from "@lixferox/odoo-client";
const client = new OdooClient({
baseUrl: "https://your-odoo-instance.com",
database: "your_db",
email: "api-user@example.com",
apiKey: "your_api_key_or_password",
companyId: 1,
});const ids = await client.search({
model: "res.partner",
domain: [["is_company", "=", true]],
limit: 10,
order: "name asc",
});
console.log(ids);new OdooClient({
baseUrl: string;
database: string;
email: string;
apiKey: string;
version?: "16.0" | "17.0" | "18.0" | "19.0";
companyId?: number;
});version is optional metadata for version-aware typing/workflows and currently does not change XML-RPC runtime requests.
create(args): Promise<number | number[]>copy(args): Promise<number>write(args): Promise<boolean>read(args): Promise<Record<string, unknown>[]>search(args): Promise<number[]>searchCount(args): Promise<number>unlink(args): Promise<boolean>
Create,Copy,Write,Read,Search,SearchCount,UnlinkOdooDomain,OdooCondition,LogicalOperatorByVersionOdooContext,OdooVersion,OrderBy
See EXAMPLES.md for full snippets.
The SDK throws if authentication fails or XML-RPC returns an error.
try {
const count = await client.searchCount({
model: "res.partner",
domain: [["customer_rank", ">", 0]],
});
console.log(count);
} catch (error) {
console.error("Odoo request failed:", error);
}src/
base.ts
index.ts
types/
common.ts
domain.ts
operations.ts
index.tsbun install
bun run test
bun run test:integration # optional (requires Odoo env vars)
bun run typecheck
bun run check
bun run buildRun against a real Odoo instance:
ODOO_TEST_BASE_URL="https://your-odoo-instance.com" \
ODOO_TEST_DATABASE="your_db" \
ODOO_TEST_EMAIL="api-user@example.com" \
ODOO_TEST_API_KEY="your_api_key_or_password" \
ODOO_TEST_COMPANY_ID="1" \
bun run test:integrationRequired: ODOO_TEST_BASE_URL, ODOO_TEST_DATABASE, ODOO_TEST_EMAIL, ODOO_TEST_API_KEY
Optional: ODOO_TEST_COMPANY_ID
See SECURITY.md.
See CONTRIBUTING.md.
See CODE_OF_CONDUCT.MD.
MIT. See LICENSE.