CLO (Command-Line Odoo) - Perform API operations on Odoo instances from the command-line.
Project description
CLO (Command-Line Odoo)
Perform API operations on Odoo instances via the command-line.
Contents
Installation
pip3 install clo
Usage
clo [--model MODEL] [--env FILE] [--inst URL] [--db NAME] [--user NAME] [--demo] [--out FILE] [--log LEVEL] [--dry-run] [--help] [--version] ACTION ...
Globals
The following parameters apply to any Action.
Options
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. | "http://localhost:8069" |
‑‑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 |
NO | Generate and use a demo instance from Odoo Cloud. | ||
‑‑out |
FILE |
NO | Where to stream the output. | |
‑‑log |
LEVEL |
NO | The level (OFF , FATAL , ERROR , WARN , INFO , DEBUG , TRACE ) of logs to produce. |
"ERROR" |
‑‑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. |
Requisites
The following inputs are required, but have multiple or special specifications. In the absense of these inputs, the program will ask for input:
--instance
can be specified using environment variableOD_INST
.--database
can be specified using environment variableOD_DATA
.--username
can be specified using environment variableOD_USER
.- The
password
(orAPI-key
) MUST BE specified using environment variableOD_PASS
.
Actions
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.
Search
clo 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.
Options
Flag(s) | Argument | Required | Description . | Default |
---|---|---|---|---|
‑‑domain ‑d |
FIELD OPERATOR VALUE |
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. |
Count
clo count [--domain FIELD OPERATOR VALUE] [--or] [--and] [--not] [--limit AMOUNT] [--help]
Returns the number of records in the current model matching the provided domain.
Options
Flag(s) | Argument | Required | Description . | Default |
---|---|---|---|---|
‑‑domain ‑d |
FIELD OPERATOR VALUE |
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. |
Read
clo read --ids ID [ID ...] [--fields FIELD [FIELD ...]] [--csv] [--help]
Retrieves the details for the records at the ID(s) specified.
Options
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. |
Find
clo 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.
Options
Flag(s) | Argument | Required | Description . | Default |
---|---|---|---|---|
‑‑domain ‑d |
FIELD OPERATOR VALUE |
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. |
Create
clo create --value FIELD VALUE [--help]
Creates new records in the current model.
Options
Flag(s) | Argument | Required | Description . | Default |
---|---|---|---|---|
‑‑value ‑v |
FIELD VALUE |
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. |
Write
clo write --ids ID [ID ...] --value FIELD VALUE [--help]
Updates existing records in the current model.
Options
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 |
FIELD VALUE |
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. |
Delete
clo delete --ids ID [ID ...] [--help]
Deletes the records from the current model.
Options
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. |
Fields
clo fields [--attributes NAME [NAME ...]] [--help]
Retrieves raw details of the fields available in the current model.
For user-friendly formatting, run clo fields explain fields
.
Options
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. |
Explain
clo explain [--verbose] [--help] {models,domains,logic,fields}
Display documentation on a specified topic.
Positional
Argument | Required | Description . | Default |
---|---|---|---|
{models,domains,logic,fields} |
YES | A topic to get further explanation on. |
Options
Flag(s) | Argument | Required | Description . | Default |
---|---|---|---|---|
‑‑verbose ‑v |
NO | Display more details. | false |
|
‑‑help ‑h |
NO | Show this help message and exit. |
See Also
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[0.5.0] - 2023-10-16
Added
- Initial feature set.
- Added tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.