Skip to content

API Reference parrot.interfaces.odoointerface

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.interfaces.odoointerface

View source

Odoo ERP interface via JSON-RPC 2.0.

Provides an async-first interface to Odoo v16+ for reading and writing business data (partners, invoices, products, inventory, etc.) through the standard JSON-RPC 2.0 endpoint.

Class JsonRpcRequest

JSON-RPC 2.0 request payload.

Fields:

Field Type Default Description
jsonrpc str '2.0' Protocol version, always "2.0".
method str 'call' RPC method, always "call" for Odoo.
id int 1 Request identifier.
params dict[str, Any] Service, method, and args to dispatch.

Class JsonRpcResponse

JSON-RPC 2.0 response payload.

Fields:

Field Type Default Description
jsonrpc str Protocol version.
id int Request identifier matching the request.
result Any None Successful result payload (None if error).
error Optional[dict[str, Any]] None Error details dict (None on success).

Alias ODOO_DATABASE

Re-exported from parrot.conf.ODOO_DATABASE.

Alias ODOO_PASSWORD

Re-exported from parrot.conf.ODOO_PASSWORD.

Alias ODOO_TIMEOUT

Re-exported from parrot.conf.ODOO_TIMEOUT.

Alias ODOO_URL

Re-exported from parrot.conf.ODOO_URL.

Alias ODOO_USERNAME

Re-exported from parrot.conf.ODOO_USERNAME.

Alias ODOO_VERIFY_SSL

Re-exported from parrot.conf.ODOO_VERIFY_SSL.

Class OdooAuthenticationError

Raised when authentication fails (invalid credentials or False uid).

Class OdooConfig

Configuration for Odoo JSON-RPC connection.

Fields:

Field Type Default Description
url str Odoo instance base URL (e.g., https://myodoo.com).
database str Odoo database name.
username str Odoo login username.
password str Odoo login password or API key.
timeout int 30 Request timeout in seconds.
verify_ssl bool True Whether to verify SSL certificates.

Class OdooConnectionError

Raised on network or connection failures.

Class OdooError

Base exception for Odoo JSON-RPC errors.

Class OdooInterface

Async interface for Odoo ERP via JSON-RPC 2.0.

Supports Odoo v16+ (Community and Enterprise).

Parameter Type Default Description
url str | None None Odoo instance base URL.
database str | None None Odoo database name.
username str | None None Odoo login username.
password str | None None Odoo login password or API key.
timeout int | None None Request timeout in seconds (default 30).
verify_ssl bool | None None Verify SSL certificates (default True).

Attributes:

Attribute Type Description
config Validated connection configuration.
uid int | None Cached user ID after successful authentication.
logger Logger instance.

Method OdooInterface.close

Close the underlying aiohttp session explicitly.

close() -> None

Method OdooInterface.version

Return Odoo server version info via the unauthenticated common service.

version() -> dict[str, Any]

Returns: dict[str, Any] — A dict with keys such as server_version, server_serie, protocol_version, server_version_info.

Raises:

  • OdooRPCError — If Odoo returns a JSON-RPC error.
  • OdooConnectionError — On network failures.

Method OdooInterface.authenticate

Authenticate with Odoo and cache the user ID.

authenticate() -> int

Returns: int — The authenticated user ID (uid).

Raises:

  • OdooAuthenticationError — If credentials are invalid (uid is False/None).
  • OdooRPCError — If Odoo returns a JSON-RPC error during login.
  • OdooConnectionError — On network failures.

Method OdooInterface.execute_kw

Execute any Odoo model method via execute_kw.

Automatically authenticates on the first call if uid is not set.

execute_kw(model: str, method: str, args: list[Any] | None = None, kwargs: dict[str, Any] | None = None) -> Any

Parameter Type Default Description
model str Odoo model technical name (e.g., "res.partner").
method str Method to call on the model (e.g., "search_read").
args list[Any] | None None Positional arguments for the model method.
kwargs dict[str, Any] | None None Keyword arguments for the model method.

Returns: Any — The result returned by Odoo for the requested operation.

Raises:

  • ValueError — If the model name is invalid.
  • OdooAuthenticationError — If auto-authentication fails.
  • OdooRPCError — On Odoo-side errors.
  • OdooConnectionError — On network failures.

Method OdooInterface.search

Search for record IDs matching the domain.

search(model: str, domain: list | None = None, offset: int = 0, limit: int | None = None, order: str | None = None) -> list[int]

Parameter Type Default Description
model str Odoo model technical name (e.g., "res.partner").
domain list | None None Odoo domain filter triplets, e.g. [("name", "=", "Bob")]. Defaults to [] (all records).
offset int 0 Number of records to skip (pagination).
limit int | None None Maximum number of records to return.
order str | None None Sort order string, e.g. "name asc".

Returns: list[int] — A list of record IDs matching the domain.

Method OdooInterface.search_read

Search and read records in a single call.

search_read(model: str, domain: list | None = None, fields: list[str] | None = None, offset: int = 0, limit: int | None = None, order: str | None = None) -> list[dict[str, Any]]

Parameter Type Default Description
model str Odoo model technical name.
domain list | None None Odoo domain filter triplets. Defaults to [].
fields list[str] | None None List of field names to return. Defaults to all fields.
offset int 0 Number of records to skip.
limit int | None None Maximum number of records to return.
order str | None None Sort order string.

Returns: list[dict[str, Any]] — A list of dicts, one per matching record.

Method OdooInterface.read

Read specific records by ID.

read(model: str, ids: list[int], fields: list[str] | None = None) -> list[dict[str, Any]]

Parameter Type Default Description
model str Odoo model technical name.
ids list[int] List of record IDs to read.
fields list[str] | None None Field names to retrieve. Defaults to all fields.

Returns: list[dict[str, Any]] — A list of dicts with the requested field values.

Method OdooInterface.create

Create one or more records.

create(model: str, values: dict[str, Any] | list[dict[str, Any]]) -> int | list[int]

Parameter Type Default Description
model str Odoo model technical name.
values dict[str, Any] | list[dict[str, Any]] A single dict of field values to create one record, or a list of dicts to create multiple records in one call.

Returns: int | list[int] — The new record ID (int) when a single dict is provided, or a list of new record IDs when a list of dicts is provided.

Method OdooInterface.write

Update existing records.

write(model: str, ids: list[int], values: dict[str, Any]) -> bool

Parameter Type Default Description
model str Odoo model technical name.
ids list[int] List of record IDs to update.
values dict[str, Any] Dict of field names → new values.

Returns: bool — True on success.

Method OdooInterface.unlink

Delete records by ID.

unlink(model: str, ids: list[int]) -> bool

Parameter Type Default Description
model str Odoo model technical name.
ids list[int] List of record IDs to delete.

Returns: bool — True on success.

Method OdooInterface.search_count

Return the count of records matching the domain.

search_count(model: str, domain: list | None = None) -> int

Parameter Type Default Description
model str Odoo model technical name.
domain list | None None Odoo domain filter. Defaults to [].

Returns: int — Integer count of matching records.

Method OdooInterface.fields_get

Get field definitions for a model.

fields_get(model: str, attributes: list[str] | None = None) -> dict[str, Any]

Parameter Type Default Description
model str Odoo model technical name.
attributes list[str] | None None List of field attribute names to include in the response (e.g., ["string", "type", "required"]). Defaults to all attributes.

Returns: dict[str, Any] — A dict mapping field technical names to their attribute dicts.

Class OdooRPCError

Raised when Odoo returns a JSON-RPC error response.

Parameter Type Default Description
message str Human-readable error message.
error_data dict[str, Any] | None None Raw error dict from the JSON-RPC response.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally