Skip to content

API Reference parrot_tools.odoo.shell

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.odoo.shell

View source

Shell execution helpers for OdooToolkit odoo-bin / odoo-cli tools.

Provides subprocess-based helpers to invoke the local odoo-bin or odoo-cli binaries (module install/upgrade, scaffold, generic CLI passthrough). All execution uses :func:asyncio.create_subprocess_exec with an explicit argv list — never shell=True.

Environment variables consumed:

  • ODOO_BIN — absolute path to the odoo-bin executable.
  • ODOO_CONF — path to the Odoo config file (passed via --conf).
  • ODOO_TEST_DATABASE — default database name when none is supplied.

When ODOO_BIN is unset or the path is not executable these helpers return a :class:ShellResult with success=False and a clear message — they never raise an unhandled exception / crash toolkit initialisation.

Attribute ALLOWED_SUBCOMMANDS

Type: frozenset[str]

Attribute DEFAULT_SHELL_TIMEOUT

Type: int

Class OdooCliCommandInput

Input schema for odoo_cli_command.

Fields:

Field Type Default Description
subcommand str A whitelisted odoo-cli/odoo-bin subcommand.
args list[str] Additional positional arguments for the subcommand.
database Optional[str] None Target database; defaults to ODOO_TEST_DATABASE.

Class OdooShellInstallInput

Input schema for odoo_shell_install_module.

Fields:

Field Type Default Description
modules list[str] Technical module names to install.
database Optional[str] None Target database; defaults to ODOO_TEST_DATABASE.
upgrade bool False When True, upgrade (-u) instead of install (-i).

Class OdooShellUpgradeInput

Input schema for odoo_shell_upgrade_module.

Intentionally omits the upgrade field — this tool always upgrades. The LLM cannot accidentally set upgrade=False on an upgrade tool.

Fields:

Field Type Default Description
modules list[str] Technical module names to upgrade.
database Optional[str] None Target database; defaults to ODOO_TEST_DATABASE.

Class ShellResult

Typed result envelope for odoo-bin / odoo-cli subprocess calls.

Always constructed internally — never from user-supplied data.

Fields:

Field Type Default Description
success bool True when the process exited with return-code 0.
returncode int The raw OS exit code.
stdout str '' Captured standard output (truncated to 8 KiB).
stderr str '' Captured standard error (truncated to 4 KiB).
argv list[str] The argv list that was executed (for auditability).
message str '' Human-readable summary for the agent.

Function build_install_argv

Build the argv list for an install or upgrade call.

build_install_argv(bin_path: str, modules: list[str], database: str, upgrade: bool = False) -> list[str]

Parameter Type Default Description
bin_path str Absolute path to the odoo-bin executable.
modules list[str] List of module technical names.
database str Target Odoo database name.
upgrade bool False When True, use -u flag; otherwise -i.

Returns: list[str] — argv list ready for :func:asyncio.create_subprocess_exec.

Raises:

  • ValueError — When any module name or the database name is invalid.

Function default_database

Return the default Odoo database from the environment.

default_database() -> str

Returns: str — Database name string (may be empty if env var is unset).

Attribute logger

Function odoo_bin_path

Return the path to the odoo-bin binary, or None when not configured.

Checks the ODOO_BIN environment variable first; falls back to shutil.which so a binary on PATH is also accepted.

odoo_bin_path() -> Optional[str]

Returns: Optional[str] — Absolute path string, or None if unavailable.

Function odoo_conf_path

Return the Odoo config file path from the environment.

odoo_conf_path() -> Optional[str]

Returns: Optional[str] — Config file path string, or None.

Function run_odoo_subprocess

Run an odoo-bin / odoo-cli subprocess and capture output.

Uses :func:asyncio.create_subprocess_exec with an explicit argv list (never shell=True). On timeout, the process is killed and a bounded drain ensures pipe buffers are flushed without deadlocking.

run_odoo_subprocess(argv: list[str], timeout: int = DEFAULT_SHELL_TIMEOUT) -> ShellResult

Parameter Type Default Description
argv list[str] The argv list. The first element must be the binary path.
timeout int DEFAULT_SHELL_TIMEOUT Maximum seconds to wait before killing the process.

Returns: ShellResult — class:ShellResult with captured stdout, stderr, returncode.

Raises:

  • asyncio.CancelledError — Re-raised immediately so task cancellation is never swallowed.

Function validate_subcommand

Validate that a subcommand is on the whitelist.

validate_subcommand(subcommand: str) -> None

Parameter Type Default Description
subcommand str The subcommand string to validate.

Raises:

  • ValueError — When the subcommand is not whitelisted.

Function validate_token

Validate that a token contains only safe characters.

Rejects empty strings, path-traversal sequences (..), tokens starting with a dot, and any character outside [a-zA-Z0-9_.-].

validate_token(token: str, label: str = 'token') -> None

Parameter Type Default Description
token str The string to validate.
label str 'token' Human-readable name for error messages.

Raises:

  • ValueError — When the token is empty, contains path traversal, or contains illegal characters.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally