Perform API operations on Odoo instances via the command-line.
pip3 install cloclo [OPTIONS] ACTION ...The following parameters apply to any Action.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑model‑m |
MODEL |
NO | The Odoo model to perform an action on. Run clo explain models [-v] to list available options. |
"res.users" |
‑‑env |
FILE |
NO | Path to a .clorc file. See Requisites below for details. |
".clorc" |
‑‑inst‑‑instance |
URL |
NO | The address of the Odoo instance. See Requisites below for details. | |
‑‑db‑‑database |
NAME |
NO | The application database to perform operations on. See Requisites below for details. | |
‑‑user |
NAME |
NO | The user to perform operations as. See Requisites below for details. | |
‑‑demo |
FILE |
NO | Generate a demo instance from Odoo Cloud and save the connection properties to FILE. |
".clorc" |
‑‑out |
FILE |
NO | Where to stream the output. | |
‑‑log |
LEVEL |
NO | The level (OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE) of logs to produce. |
"WARN" |
‑‑dry‑run |
NO | Perform a "practice" run of the action; implies --log=DEBUG. |
false |
|
‑‑help‑h |
NO | Show this help message and exit. | ||
‑‑version |
NO | Show version of this program. |
The following inputs are required, but have multiple or special specifications. In the absense of these inputs, the program will ask for input:
--instancecan be specified using environment variableCLO_INSTANCE.--databasecan be specified using environment variableCLO_DATABASE.--usernamecan be specified using environment variableCLO_USERNAME.- The
password(orAPI-key) MUST BE specified using environment variableCLO_PASSWORD.
cloalso looks for a.clorcfile in the working directory that contain these values, or the file specified by--env FILE, if it exists.
The Odoo instance is queried, or operated on, using ACTIONS. Each ACTION has it's own set of arguements; run clo ACTION --help for specific details.
clo [OPTIONS] ACTION ... search [[-o|-n|-a] -d FIELD OPERATOR VALUE [-d ...]] [--offset POSITION] [--limit AMOUNT] [--order FIELD] [--count] [-h]Searches for record IDs based on the search domain.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑domain‑d |
FIELDOPERATORVALUE |
NO | A set of criterion to filter the search by (run clo explain domains for details). This option can be specified multiple times. |
[] |
‑‑or‑o |
NO | A logical OR, placed before two or more domains (arity 2). Run clo explain logic for more details. |
||
‑‑and‑a |
NO | A logical AND to place before two or more domains (arity 2). Run clo explain logic for more details. |
||
‑‑not‑n |
NO | A logical OR to place before a signle domain (arity 1). Run clo explain logic for more details. |
||
‑‑offset |
POSITION |
NO | Number of results to ignore. | 0 |
‑‑limit |
AMOUNT |
NO | Maximum number of records to return. | |
‑‑order |
FIELD |
NO | The field to sort the records by. | |
‑‑raw‑r |
NO | Format output as space-separated IDs rather than pretty JSON. | false |
|
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... count [--domain FIELD OPERATOR VALUE] [--or] [--and] [--not] [--limit AMOUNT] [--help]Returns the number of records in the current model matching the provided domain.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑domain‑d |
FIELDOPERATORVALUE |
NO | A set of criterion to filter the search by (run clo explain domains for details). This option can be specified multiple times. |
[] |
‑‑or‑o |
NO | A logical OR, placed before two or more domains (arity 2). Run clo explain logic for more details. |
||
‑‑and‑a |
NO | A logical AND to place before two or more domains (arity 2). Run clo explain logic for more details. |
||
‑‑not‑n |
NO | A logical OR to place before a signle domain (arity 1). Run clo explain logic for more details. |
||
‑‑limit |
AMOUNT |
NO | Maximum number of records to return. | |
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... read --ids ID [ID ...] [--fields FIELD [FIELD ...]] [--csv] [--help]Retrieves the details for the records at the ID(s) specified.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑ids‑i |
ID |
YES | The ID number(s) of the record(s) to perform the action on. Specifying - expects a space-separated list from STDIN. |
|
‑‑fields‑f |
FIELD |
NO | Field names to return (default is all fields). | [] |
‑‑csv |
NO | If True, outputs records in CSV format. |
false |
|
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... find [[-o|-n|-a] -d FIELD OPERATOR VALUE [-d ...]] [-f FIELD ...] [--offset POSITION] [--limit AMOUNT] [--order FIELD] [--csv [FILE]] [--help]A shortcut that combines search and read into one execution.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑domain‑d |
FIELDOPERATORVALUE |
NO | A set of criterion to filter the search by (run clo explain domains for details). This option can be specified multiple times. |
[] |
‑‑or‑o |
NO | A logical OR, placed before two or more domains (arity 2). Run clo explain logic for more details. |
||
‑‑and‑a |
NO | A logical AND to place before two or more domains (arity 2). Run clo explain logic for more details. |
||
‑‑not‑n |
NO | A logical OR to place before a signle domain (arity 1). Run clo explain logic for more details. |
||
‑‑fields‑f |
FIELD |
NO | Field names to return (default is all fields). | [] |
‑‑offset |
POSITION |
NO | Number of results to ignore. | 0 |
‑‑limit |
AMOUNT |
NO | Maximum number of records to return. | |
‑‑order |
FIELD |
NO | The field to sort the records by. | |
‑‑csv |
NO | If True, outputs records in CSV format. |
false |
|
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... create --value FIELD VALUE [--help]Creates new records in the current model.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑value‑v |
FIELDVALUE |
YES | Key/value pair(s) that correspond to the field and assigment to be made, respectively. | |
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... write --ids ID [ID ...] --value FIELD VALUE [--help]Updates existing records in the current model.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑ids‑i |
ID |
YES | The ID number(s) of the record(s) to perform the action on. Specifying - expects a space-separated list from STDIN. |
|
‑‑value‑v |
FIELDVALUE |
YES | Key/value pair(s) that correspond to the field and assigment to be made, respectively. | |
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... delete --ids ID [ID ...] [--help]Deletes the records from the current model.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑ids‑i |
ID |
YES | The ID number(s) of the record(s) to perform the action on. Specifying - expects a space-separated list from STDIN. |
|
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... fields [--attributes NAME [NAME ...]] [--help]Retrieves raw details of the fields available in the current model.
For user-friendly formatting, run clo [OPTIONS] ACTION ... fields explain fields.
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑attributes‑‑attr‑a |
NAME |
NO | Attribute(s) to return for each field, all if empty or not provided. | |
‑‑help‑h |
NO | Show this help message and exit. |
clo [OPTIONS] ACTION ... explain [--verbose] [--help] {models,domains,logic,fields}Display documentation on a specified topic.
| Argument | Required | Description . | Default |
|---|---|---|---|
{models,domains,logic,fields} |
YES | A topic to get further explanation on. |
| Flag(s) | Argument | Required | Description . | Default |
|---|---|---|---|---|
‑‑verbose‑v |
NO | Display more details. | false |
|
‑‑help‑h |
NO | Show this help message and exit. |
The following breakdowns apply to search-style ACTIONS.
A domain is a set of criteria, each criterion being a throuple of (FIELD, OPERATOR, VALUE) where:
FIELD: A field name of the current model, or a relationship traversal through a Many2one
using dot-notation.
OPERATOR: An operand used to compare the FIELD with the value. Valid operators are:
=, !=, >, >=, <, <= Standard comparison operators.
=? Unset or equals to (_returns true if value is either None or
False, otherwise behaves like `=`_).
=[i]like Matches `FIELD` against the value pattern. An underscore (_`_`_)
in the pattern matches any single character; a percent sign
(_`%`_) matches any string of zero or more characters. `=ilike`
makes the search case-insensitive.
[not ][i]like Matches (_or inverse-matches_) `FIELD` against the %value%
pattern. Similar to `=[i]like` but wraps value with `%` before
matching.
[not ]in Is—or is not—equal to any of the items from value, value should
be a list of items.
child_of Is a child (_descendant�[2m_) of a value record (_�[2mvalue can
be either one item or a list of items_). Takes the semantics
of the model into account (_i.e following the relationship
`FIELD` named by `VALUE`_).
parent_of Is a child (_ascendant�[2m_) of a value record (_�[2mvalue can
be either one item or a list of items_). Takes the semantics
of the model into account (_i.e following the relationship
`FIELD` named by `VALUE`_).
VALUE: Variable type, must be comparable (through OPERATOR) to the named FIELD.
Domain criteria can be combined using logical operators in prefix form:
--or -d login = user -d name = "John Smith" -d email = user@domain.com
is equivalent to login == "user" || name == "John Smith" || email == "user@domain.com"
--not -d login = user` or `-d login '!=' user
are equivalent to login != "user". --not is generally unneeded, save for negating the OPERATOR, child_of, or parent_of.
--and -d login = user -d name = "John Smith"
is equivalent to login == "user" && name == "John Smith"; though, successive domainsimply --and.
