OdooInspector

OdooInspector is the structured runtime inspection API for XMLIDs, cron records, models, fields, PostgreSQL metadata, and trusted embedded execution.

It builds on OdooCodeExecutor and OdooQuery so callers can prefer first-class inspection methods over ad hoc shell snippets.

Structured runtime inspection helpers built on top of OdooCodeExecutor.

class oduit.odoo_inspector.OdooInspector(config: ConfigProvider | dict[str, Any])[source]

Bases: object

Expose structured Odoo inspection workflows for CLI and Python callers.

__init__(config: ConfigProvider | dict[str, Any])[source]
execute_code(code: str, *, database: str | None = None, commit: bool = False, timeout: float = 30.0) dict[str, Any][source]

Execute trusted arbitrary Python within Odoo via the embedded runtime.

inspect_ref(xmlid: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Resolve one XMLID and return stable record metadata.

inspect_cron(xmlid: str, *, trigger: bool = False, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Inspect one cron job and optionally trigger it.

inspect_modules(*, state: str | None = None, names_only: bool = False, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

List runtime addon inventory from ir.module.module.

inspect_subtypes(model: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

List mail.message.subtype records for one model.

inspect_model(model: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Inspect model registration metadata.

inspect_field(model: str, field: str, *, with_db: bool = False, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Inspect one ORM field, optionally including DB-level metadata.

inspect_recordset(expression: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Execute a trusted recordset expression as an escape hatch.

describe_table(table_name: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Describe columns for one PostgreSQL table.

describe_column(table_name: str, column_name: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Describe one PostgreSQL column.

list_constraints(table_name: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

List PostgreSQL constraints for one table.

list_tables(pattern: str | None = None, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

List PostgreSQL tables, optionally filtered by an ILIKE pattern.

inspect_m2m(model: str, field: str, *, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Inspect Many2many relation-table metadata for one ORM field.

performance_table_scans(*, limit: int = 20, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Return tables with the highest sequential scan counts.

performance_slow_queries(*, limit: int = 10, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Return the slowest statements from pg_stat_statements when available.

performance_indexes(*, limit: int = 20, database: str | None = None, timeout: float = 30.0) dict[str, Any][source]

Return simple table index-usage metrics.

Usage Examples

from oduit import ConfigLoader, OdooInspector

loader = ConfigLoader()
config = loader.load_config("dev")
inspector = OdooInspector(config)

xmlid = inspector.inspect_ref("base.action_partner_form")
model = inspector.inspect_model("res.partner")
field = inspector.inspect_field("res.partner", "email", with_db=True)
table = inspector.describe_table("res_partner")
scans = inspector.performance_table_scans(limit=10)