Script with JSON output¶
How to use odoo-work-cli from shell scripts. Never parse the tables: long
names shift the columns.
Ask for JSON¶
Every reading and writing command accepts --json (= --format json) and
--format jsonl:
odoo-work-cli entries --week 2026-W15 --json | jq '.[] | {id, project, minutes}'
odoo-work-cli clock status --json | jq .clocked_in
odoo-work-cli entries add --project-id 42 --hours 1:30 --description "Review" --json | jq .id
$ odoo-work-cli clock list --date 2026-04-08 --json
[
{
"id": 4606,
"employee_id": 7,
"employee": "Alex Demo",
"check_in": "2026-04-08T08:30:00+02:00",
"check_out": "2026-04-08T12:00:00+02:00",
"running": false,
"worked_hours": 3.5,
"worked_minutes": 210
},
{
"id": 4607,
"employee_id": 7,
"employee": "Alex Demo",
"check_in": "2026-04-08T12:30:00+02:00",
"check_out": "2026-04-08T17:00:00+02:00",
"running": false,
"worked_hours": 4.5,
"worked_minutes": 270
}
]
An empty result is [], never empty output. Field names never change; new
fields may appear. Details per object: JSON output.
Handle errors¶
With --json, a failure prints exactly one object on stdout and exits
with code 1:
$ odoo-work-cli entries delete 999 --json
{
"error": {
"kind": "not_found",
"message": "timesheet entry 999 not found"
}
}
Branch on kind, not on message:
out=$(odoo-work-cli clock edit --date 2026-09-14 --in 08:00 --out 16:30 --create-only --json)
case $? in
0) echo "created #$(jq .id <<<"$out")" ;;
*) case $(jq -r .error.kind <<<"$out") in
conflict) echo "day already has a record, skipped" ;;
*) jq -r .error.message <<<"$out" >&2; exit 1 ;;
esac ;;
esac
All kinds: Errors and exit codes.
jsonl¶
--format jsonl prints one compact object per line, handy for while read:
Validate against the schemas¶
The JSON Schemas (draft 2020-12) are in
internal/output/schemas/
and are the contract. The test suite checks every command's output against
them.