Skip to content

Api

clo.api

XMLRPC API implementation

clo.api.Common

Common(url=None, database=None, username=None, password=Secret(''))

A singleton class representing the Odoo server's common XMLRPC connection.

database (str, optional): The name of Odoo instance database. username (str, optional): The user to authenitcate. password (Secret, optional): The user's password.

clo.api.Common.APIVersion

Bases: TypedDict

A collection of version metadata properties:

  • server_version str: The major and minor version.
  • server_version_info (int, int, int, str, int): The major, minor, patch, release, and build items.
  • server_serie str
  • protocol_version int: The API protocol version.

clo.api.Common.Load classmethod

Load()

Load the Odoo server's common XMLRPC connection.

clo.api.Common.Authenticate classmethod

Authenticate(*, username=None, password=None, exit_on_fail=True)

Log in to an Odoo instance's XMLRPC API.

PARAMETER DESCRIPTION
username

The user to authenitcate.

TYPE: str DEFAULT: None

password

The user's password.

TYPE: Secret DEFAULT: None

exit_on_fail

If True, calls for an exit on failure. Defaults to True.

TYPE: bool DEFAULT: True

RAISES DESCRIPTION
LookupError

Raised when authenitcation fails in any way.

RETURNS DESCRIPTION
int

The ID of the authenitcated user.

TYPE: int

clo.api.Common.Version classmethod

Version()

Retrieve version data about the Odoo instance.

RETURNS DESCRIPTION
APIVersion

The version properties.

TYPE: APIVersion

clo.api.Common.Demo classmethod

Demo()

Retrieve demo credentials from Odoo Cloud.

RETURNS DESCRIPTION
Credentials

Teh credentials, in the for of Environment Variable declarations.

TYPE: Credentials

clo.api.Common.HandleProtocol staticmethod

HandleProtocol(exception)

A handler for protocal errors.

PARAMETER DESCRIPTION
exception

The protocol exception.

TYPE: ProtocolError

RETURNS DESCRIPTION
Literal[200]

Literal[200]: Standard exit code for protocol errors in clo.

clo.api.Common.HandleFault staticmethod

HandleFault(exception)

A handler for fault errors.

PARAMETER DESCRIPTION
exception

The fault exception.

TYPE: ProtocolError

RETURNS DESCRIPTION
Literal[100]

Literal[100]: Standard exit code for protocol errors in clo.

clo.api.Model

Model(name)

Performs operations on the records of a specified Odoo model.

clo.api.Model.Search

Search(domain=[], /, offset=0, limit=None, order=None)

Searches for record IDs based on the search domain.

PARAMETER DESCRIPTION
domain

A set of criterion to filter the search by.

TYPE: list[Union[Domain, Logic]] DEFAULT: []

offset

Number of results to ignore.

TYPE: int DEFAULT: 0

limit

Maximum number of records to return.

TYPE: int | None DEFAULT: None

order

The field to sort the records by.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
list[int]

list[int]: A list of matched record IDs.

clo.api.Model.Count

Count(domain=[], /, limit=None)

Returns the number of records in the current model matching the provided domain.

PARAMETER DESCRIPTION
domain

A set of criterion to filter the search by.

TYPE: list[Union[Domain, Logic]] DEFAULT: []

limit

Maximum number of records to return.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
int

The count of matched records.

TYPE: int

clo.api.Model.Find

Find(domain=[], /, fields=[], offset=0, limit=None, order=None)

A shortcut that combines search and read into one execution.

PARAMETER DESCRIPTION
domain

A set of criterion to filter the search by.

TYPE: list[Union[Domain, Logic]] DEFAULT: []

fields

Field names to return (default is all fields).

TYPE: list[str] DEFAULT: []

offset

Number of results to ignore.

TYPE: int DEFAULT: 0

limit

Maximum number of records to return.

TYPE: int | None DEFAULT: None

order

The field to sort the records by.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
list[dict[str, Any]]

list[dict[str, Any]]: A list of matched record data.

clo.api.Model.Read

Read(ids, /, fields=[])

Retrieves the details for the records at the ID(s) specified.

PARAMETER DESCRIPTION
ids

The ID number(s) of the record(s) to perform the action on. Specifying - expects a space-separated list from STDIN.

TYPE: list[int]

fields

Field names to return (default is all fields).

TYPE: list[str] DEFAULT: []

RETURNS DESCRIPTION
list[dict[str, Any]]

list[dict[str, Any]]: A list of record data.

clo.api.Model.Write

Write(ids, values)

Updates existing records in the current model.

PARAMETER DESCRIPTION
ids

The ID number(s) of the record(s) to perform the action on. Specifying - expects a space-separated list from STDIN.

TYPE: list[int]

values

Key/value pair(s) that correspond to the field and assigment to be made, respectively.

TYPE: dict[str, Any]

RETURNS DESCRIPTION
bool

True, if the operation was successful.

TYPE: bool

clo.api.Model.Create

Create(values)

Creates new records in the current model.

PARAMETER DESCRIPTION
values

Key/value pair(s) that correspond to the field and assigment to be made, respectively.

TYPE: dict[str, Any]

RETURNS DESCRIPTION
int

The ID of the created record.

TYPE: int

clo.api.Model.Delete

Delete(ids)

Deletes the records from the current model.

PARAMETER DESCRIPTION
ids

The ID number(s) of the record(s) to perform the action on. Specifying - expects a space-separated list from STDIN.

TYPE: list[int]

RETURNS DESCRIPTION
bool

True, if the operation was successful.

TYPE: bool

clo.api.Model.Fields

Fields(*, attributes=[])

Retrieves raw details of the fields available in the current model. For user-friendly formatting, run %(prog)s explain fields

PARAMETER DESCRIPTION
attributes

Attribute(s) to return for each field, all if empty or not provided.

TYPE: list[str] DEFAULT: []

RETURNS DESCRIPTION
dict[str, dict[str, Any]]

dict[str, dict[str, Any]]: A collection of fields and their metadata.