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:
|
password |
The user's password.
TYPE:
|
exit_on_fail |
If
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
LookupError
|
Raised when authenitcation fails in any way. |
| RETURNS | DESCRIPTION |
|---|---|
int
|
The ID of the authenitcated user.
TYPE:
|
clo.api.Common.Version
classmethod
Version()
Retrieve version data about the Odoo instance.
| RETURNS | DESCRIPTION |
|---|---|
APIVersion
|
The version properties.
TYPE:
|
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:
|
clo.api.Common.HandleProtocol
staticmethod
HandleProtocol(exception)
A handler for protocal errors.
| PARAMETER | DESCRIPTION |
|---|---|
exception |
The protocol exception.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Literal[200]
|
Literal[200]: Standard exit code for protocol errors in |
clo.api.Common.HandleFault
staticmethod
HandleFault(exception)
A handler for fault errors.
| PARAMETER | DESCRIPTION |
|---|---|
exception |
The fault exception.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Literal[100]
|
Literal[100]: Standard exit code for protocol errors in |
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. |
offset |
Number of results to ignore.
TYPE:
|
limit |
Maximum number of records to return.
TYPE:
|
order |
The field to sort the records by.
TYPE:
|
| 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. |
limit |
Maximum number of records to return.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The count of matched records.
TYPE:
|
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. |
fields |
Field names to return (default is all fields).
TYPE:
|
offset |
Number of results to ignore.
TYPE:
|
limit |
Maximum number of records to return.
TYPE:
|
order |
The field to sort the records by.
TYPE:
|
| 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
TYPE:
|
fields |
Field names to return (default is all fields).
TYPE:
|
| 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
TYPE:
|
values |
Key/value pair(s) that correspond to the field and assigment to be made, respectively.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
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:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The ID of the created record.
TYPE:
|
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
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
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:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, dict[str, Any]]
|
dict[str, dict[str, Any]]: A collection of fields and their metadata. |