Async API¶
Vodoo provides a full async API via AsyncOdooClient. It exposes the same domain namespaces as the sync client, but all methods are async and use httpx for non-blocking HTTP.
Quick Start¶
import asyncio
from vodoo import AsyncOdooClient, OdooConfig
config = OdooConfig(
url="https://my.odoo.com",
database="mydb",
username="bot@example.com",
password="api-key",
)
async def main():
async with AsyncOdooClient(config) as client:
partners = await client.search_read(
"res.partner",
domain=[["is_company", "=", True]],
fields=["name", "email"],
limit=10,
)
for p in partners:
print(p["name"])
asyncio.run(main())
Domain Namespaces¶
The async client has the same namespace properties as the sync client. All namespace methods must be awaited:
async with AsyncOdooClient(config) as client:
tickets = await client.helpdesk.list(limit=5)
leads = await client.crm.list(domain=[["type", "=", "opportunity"]])
await client.helpdesk.note(ticket_id=42, message="Checked via async API")
Concurrent Requests¶
The async API shines when you need to make multiple independent calls:
import asyncio
async with AsyncOdooClient(config) as client:
# Run all three queries concurrently
tickets, leads, tasks = await asyncio.gather(
client.helpdesk.list(limit=10),
client.crm.list(limit=10),
client.tasks.list(limit=10),
)
Reference¶
AsyncOdooClient¶
AsyncOdooClient
¶
AsyncOdooClient(config: OdooConfig, *, transport: AsyncOdooTransport | None = None, auto_detect: bool = True)
Async Odoo client for external API access.
Wraps an AsyncOdooTransport to provide a convenient async interface. Supports both legacy JSON-RPC (Odoo 14-18) and JSON-2 API (Odoo 19+).
Can be used as an async context manager::
async with AsyncOdooClient(config) as client:
records = await client.search_read("res.partner", limit=5)
Initialize async Odoo client.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Odoo configuration
TYPE:
|
transport
|
Explicit transport instance (skips auto-detection).
When auto_detect is
TYPE:
|
auto_detect
|
If True, probe JSON-2 first then fall back to legacy on first use. If False, use legacy directly.
TYPE:
|
Source code in src/vodoo/aio/client.py
transport
property
¶
transport: AsyncOdooTransport
The underlying transport (raises if not yet initialised).
close
async
¶
get_uid
async
¶
execute
async
¶
Execute a method on an Odoo model.
Source code in src/vodoo/aio/client.py
execute_sudo
async
¶
Execute a method as another user using sudo.
Source code in src/vodoo/aio/client.py
search
async
¶
search(model: str, domain: list[Any] | None = None, limit: int | None = None, offset: int = 0, order: str | None = None) -> list[int]
Search for records.
Source code in src/vodoo/aio/client.py
read
async
¶
Read records by IDs.
Source code in src/vodoo/aio/client.py
search_read
async
¶
search_read(model: str, domain: list[Any] | None = None, fields: list[str] | None = None, limit: int | None = None, offset: int = 0, order: str | None = None) -> list[dict[str, Any]]
Search and read records in one call.
Source code in src/vodoo/aio/client.py
create
async
¶
Create a new record.
Source code in src/vodoo/aio/client.py
write
async
¶
Update records.
unlink
async
¶
fields_get
async
¶
fields_get(model: str, fields: list[str] | None = None, attributes: list[str] | None = None) -> dict[str, Any]
Return field definitions for a model.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Odoo model name (e.g.,
TYPE:
|
fields
|
Optional list of field names to inspect.
TYPE:
|
attributes
|
Optional list of field attributes to return
(e.g.,
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary mapping field names to their attribute dicts. |
Source code in src/vodoo/aio/client.py
name_search
async
¶
name_search(model: str, name: str, domain: list[Any] | None = None, limit: int = 7) -> list[tuple[int, str]]
Autocomplete search returning (id, display_name) pairs.
Source code in src/vodoo/aio/client.py
AsyncOdooTransport¶
transport
¶
Async Odoo JSON-RPC transport abstraction.
- AsyncLegacyTransport: Odoo 14-18 using POST /jsonrpc with service/method/args envelope
- AsyncJSON2Transport: Odoo 19+ using POST /json/2/unasync, code generation, runtime indirection) adds build or
type-system complexity that outweighs the cost of ~260 lines of mechanical duplication
in a library of this size.
AsyncOdooTransport
¶
AsyncOdooTransport(url: str, database: str, username: str, password: str, *, timeout: int = 30, retry: RetryConfig | None = None, extra_headers: dict[str, str] | None = None)
Bases: ABC
Abstract base for async Odoo RPC transports.
Mirrors :class:vodoo.transport.OdooTransport with async methods.
Source code in src/vodoo/aio/transport.py
get_uid
async
¶
authenticate
abstractmethod
async
¶
Authenticate and return the user ID.
| RAISES | DESCRIPTION |
|---|---|
AuthenticationError
|
If authentication fails. |
execute_kw
abstractmethod
async
¶
Execute a method on an Odoo model (execute_kw equivalent).
call_service
abstractmethod
async
¶
close
async
¶
search_read
async
¶
search_read(model: str, domain: list[Any] | None = None, fields: list[str] | None = None, limit: int | None = None, offset: int = 0, order: str | None = None) -> list[dict[str, Any]]
Search and read records.
Source code in src/vodoo/aio/transport.py
search
async
¶
search(model: str, domain: list[Any] | None = None, limit: int | None = None, offset: int = 0, order: str | None = None) -> list[int]
Search for record IDs.
Source code in src/vodoo/aio/transport.py
read
async
¶
Read records by IDs.
Source code in src/vodoo/aio/transport.py
create
async
¶
Create a record and return its ID.
Source code in src/vodoo/aio/transport.py
write
async
¶
unlink
async
¶
name_search
async
¶
name_search(model: str, name: str, domain: list[Any] | None = None, limit: int = 7) -> list[tuple[int, str]]
Autocomplete search returning (id, display_name) pairs.
Source code in src/vodoo/aio/transport.py
AsyncLegacyTransport
¶
AsyncLegacyTransport(url: str, database: str, username: str, password: str, *, timeout: int = 30, retry: RetryConfig | None = None, extra_headers: dict[str, str] | None = None)
Bases: AsyncOdooTransport
Async Odoo 14-18 legacy JSON-RPC transport.
Source code in src/vodoo/aio/transport.py
AsyncJSON2Transport
¶
AsyncJSON2Transport(url: str, database: str, username: str, password: str, *, timeout: int = 30, retry: RetryConfig | None = None, extra_headers: dict[str, str] | None = None)
Bases: AsyncOdooTransport
Async Odoo 19+ JSON-2 API transport.