Builders

The builders module contains the structured command builders used by OdooOperations and ProcessManager.

New builder pattern implementation for command construction. Provides proper separation of concerns and fluent interfaces.

oduit.builders.odoo_series_major(value: Any | None) int | None[source]
class oduit.builders.CommandOperation(command: list[str], operation_type: str, database: str | None = None, modules: list[str] = <factory>, test_tags: str | None = None, extra_args: list[str] = <factory>, is_odoo_command: bool = True, expected_result_fields: dict[str, ~typing.Any] = <factory>, result_parsers: list[str] = <factory>)[source]

Bases: object

Structured command operation containing both command and metadata.

command: list[str]
operation_type: str
database: str | None = None
modules: list[str]
test_tags: str | None = None
extra_args: list[str]
is_odoo_command: bool = True
expected_result_fields: dict[str, Any]
result_parsers: list[str]
__init__(command: list[str], operation_type: str, database: str | None = None, modules: list[str] = <factory>, test_tags: str | None = None, extra_args: list[str] = <factory>, is_odoo_command: bool = True, expected_result_fields: dict[str, ~typing.Any] = <factory>, result_parsers: list[str] = <factory>) None
class oduit.builders.AbstractCommandBuilder(config_provider: ConfigProvider)[source]

Bases: ABC

Abstract base class for command builders following the Builder pattern

__init__(config_provider: ConfigProvider)[source]
abstractmethod build() list[str][source]

Build and return the final command as a list of strings

abstractmethod build_operation() CommandOperation[source]

Build and return a structured CommandOperation with metadata

abstractmethod reset() None[source]

Reset the builder to initial state for reuse

class oduit.builders.BaseOdooCommandBuilder(config_provider: ConfigProvider)[source]

Bases: AbstractCommandBuilder

Base Odoo command builder with common functionality

__init__(config_provider: ConfigProvider)[source]
disable_http() BaseOdooCommandBuilder[source]

Disable all HTTP-related options and enable –no-http.

database(db_name: str) BaseOdooCommandBuilder[source]

Set database name

addons_path(path: str) BaseOdooCommandBuilder[source]

Set addons path

load(modules: str) BaseOdooCommandBuilder[source]

Set list of server-wide modules to load.

log_level(level: str) BaseOdooCommandBuilder[source]

Set log level (info, warn, error, debug)

log_handler(handler: str) BaseOdooCommandBuilder[source]

Set LOGGER:LEVEL, enables LOGGER at the provided LEVEL

log_web(enabled: bool = True) BaseOdooCommandBuilder[source]

enables DEBUG logging of HTTP requests and responses

log_sql(enabled: bool = True) BaseOdooCommandBuilder[source]

enables DEBUG logging of SQL querying

syslog(enabled: bool = True) BaseOdooCommandBuilder[source]

Enable: logs to the system’s event logger

db_maxconn(maxconn: int) BaseOdooCommandBuilder[source]

Set maximum number of database connections

db_maxconn_gevent(maxconn: int) BaseOdooCommandBuilder[source]

Set maximum number of database connections

db_user(user: str) BaseOdooCommandBuilder[source]

Set database user

db_password(password: str) BaseOdooCommandBuilder[source]

Set database password

db_host(hostname: str) BaseOdooCommandBuilder[source]

Set database host

db_filter(filter: str) BaseOdooCommandBuilder[source]

Set database filter

db_template(template: str) BaseOdooCommandBuilder[source]

Set database template

http_port(port: int) BaseOdooCommandBuilder[source]

Set HTTP port

gevent_port(port: int) BaseOdooCommandBuilder[source]

Set GEVENT port

workers(workers: int) BaseOdooCommandBuilder[source]

Set workers

limit_request(limit: int) BaseOdooCommandBuilder[source]

Set limit-request

limit_memory_soft(limit: int) BaseOdooCommandBuilder[source]

Set limit-memory-soft

limit_memory_hard(limit: int) BaseOdooCommandBuilder[source]

Set limit-memory-hard

limit_time_cpu(limit: int) BaseOdooCommandBuilder[source]

Set limit-time-cpu

limit_time_real(limit: int) BaseOdooCommandBuilder[source]

Set limit-time-real

max_cron_threads(threads: int) BaseOdooCommandBuilder[source]

Set max-cron-threads

limit_time_worker_cron(limit: int) BaseOdooCommandBuilder[source]

Set limit-time-worker-cron

http_interface(interface: str) BaseOdooCommandBuilder[source]

Set http interface

data_dir(path: str) BaseOdooCommandBuilder[source]

Set data directory

config_file(path: str) BaseOdooCommandBuilder[source]

Set config file path

dev(features: str = 'all') BaseOdooCommandBuilder[source]

Enable dev mode with specified features

load_language(languages: str) BaseOdooCommandBuilder[source]

specifies the languages (separated by commas) for the translations

language(language: str) BaseOdooCommandBuilder[source]

Set the language of the translation file use it with i18n-export or i18n-import

i18n_export(filename: str) BaseOdooCommandBuilder[source]

Set i18n export filename

i18n_import(filename: str) BaseOdooCommandBuilder[source]

Set i18n import filename

i18n_overwrite(enabled: bool = True) BaseOdooCommandBuilder[source]

Enable i18n overwrite

modules(modules: str) BaseOdooCommandBuilder[source]

Set list of modules to export

no_http(enabled: bool = True) BaseOdooCommandBuilder[source]

Disable HTTP server

proxy_mode(enabled: bool = True) BaseOdooCommandBuilder[source]

Enables HTTP proxy

stop_after_init(enabled: bool = True) BaseOdooCommandBuilder[source]

Stop after module initialization

install_module(module: str) BaseOdooCommandBuilder[source]

Install a module

update_module(module: str) BaseOdooCommandBuilder[source]

Update a module

shell_interface(interface: str) BaseOdooCommandBuilder[source]

Set shell interface (ipython, ptpython, bpython, python)

without_demo(modules: str) BaseOdooCommandBuilder[source]

Disable demo data for specified modules

with_demo(enabled: bool = True) BaseOdooCommandBuilder[source]

Install module with demo data

reset() None[source]

Reset builder to initial state

build() list[str][source]

Build the final command list

build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.BaseI18nCommandBuilder(config_provider: ConfigProvider, odoo_series: Any)[source]

Bases: BaseOdooCommandBuilder

Shared base for version-aware i18n command builders.

__init__(config_provider: ConfigProvider, odoo_series: Any)[source]
property is_native_i18n: bool
property strategy: str
property odoo_series: str
overwrite(enabled: bool = True) BaseI18nCommandBuilder[source]
log_level(level: str) BaseI18nCommandBuilder[source]

Set log level (info, warn, error, debug)

no_http(enabled: bool = True) BaseI18nCommandBuilder[source]

Disable HTTP server

stop_after_init(enabled: bool = True) BaseI18nCommandBuilder[source]

Stop after module initialization

disable_http() BaseI18nCommandBuilder[source]

Disable all HTTP-related options and enable –no-http.

class oduit.builders.RunCommandBuilder(config_provider: ConfigProvider)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for run commands

__init__(config_provider: ConfigProvider)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.OdooTestCoverageCommandBuilder(config_provider: ConfigProvider, module: str)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for test commands with coverage

__init__(config_provider: ConfigProvider, module: str)[source]
test_module(module: str, install: bool = False) OdooTestCoverageCommandBuilder[source]

Configure module testing

test_file(file_path: str) OdooTestCoverageCommandBuilder[source]

Set specific test file

test_tags(tags: str) OdooTestCoverageCommandBuilder[source]

Set test tags filter

build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.OdooTestCommandBuilder(config_provider: ConfigProvider)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for test commands

__init__(config_provider: ConfigProvider)[source]
test_module(module: str, install: bool = False) OdooTestCommandBuilder[source]

Configure module testing

test_file(file_path: str) OdooTestCommandBuilder[source]

Set specific test file

test_tags(tags: str) OdooTestCommandBuilder[source]

Set test tags filter

build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.ShellCommandBuilder(config_provider: ConfigProvider)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for shell commands

__init__(config_provider: ConfigProvider)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.UpdateCommandBuilder(config_provider: ConfigProvider, module: str)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for update commands

__init__(config_provider: ConfigProvider, module: str)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.InstallCommandBuilder(config_provider: ConfigProvider, module: str)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for install commands

__init__(config_provider: ConfigProvider, module: str)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.I18nExportCommandBuilder(config_provider: ConfigProvider, modules: Sequence[str], languages: Sequence[str] | None = None, output: str | None = None, *, odoo_series: Any)[source]

Bases: BaseI18nCommandBuilder

Build version-aware translation export commands.

__init__(config_provider: ConfigProvider, modules: Sequence[str], languages: Sequence[str] | None = None, output: str | None = None, *, odoo_series: Any)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.I18nImportCommandBuilder(config_provider: ConfigProvider, files: Sequence[str], language: str, *, overwrite: bool = False, odoo_series: Any)[source]

Bases: BaseI18nCommandBuilder

Build version-aware translation import commands.

__init__(config_provider: ConfigProvider, files: Sequence[str], language: str, *, overwrite: bool = False, odoo_series: Any)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.I18nLoadLanguageCommandBuilder(config_provider: ConfigProvider, languages: Sequence[str], *, odoo_series: Any)[source]

Bases: BaseI18nCommandBuilder

Build version-aware language-loading commands.

__init__(config_provider: ConfigProvider, languages: Sequence[str], *, odoo_series: Any)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.LanguageCommandBuilder(config_provider: ConfigProvider, module: str, filename: str, language: str, odoo_series: Any | None = None)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for language export commands

__init__(config_provider: ConfigProvider, module: str, filename: str, language: str, odoo_series: Any | None = None)[source]
log_level(level: str) LanguageCommandBuilder[source]

Set log level (info, warn, error, debug)

no_http(enabled: bool = True) LanguageCommandBuilder[source]

Disable HTTP server

stop_after_init(enabled: bool = True) LanguageCommandBuilder[source]

Stop after module initialization

disable_http() LanguageCommandBuilder[source]

Disable all HTTP-related options and enable –no-http.

reset() None[source]

Reset builder to initial state

build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.VersionCommandBuilder(config_provider: ConfigProvider)[source]

Bases: BaseOdooCommandBuilder

Specialized builder for version command

__init__(config_provider: ConfigProvider)[source]
build_operation() CommandOperation[source]

Build a CommandOperation with base metadata. Subclasses should override.

class oduit.builders.DatabaseCommandBuilder(config_provider: ConfigProvider, with_sudo: bool = True)[source]

Bases: AbstractCommandBuilder

Builder for database-related commands

__init__(config_provider: ConfigProvider, with_sudo: bool = True)[source]
drop_command() DatabaseCommandBuilder[source]

Build database drop command

create_role_command(db_user: str | None = None) DatabaseCommandBuilder[source]

Build database create role command

create_extension_command(extension: str) DatabaseCommandBuilder[source]

Build database create role command

alter_role_command(db_user: str | None = None) DatabaseCommandBuilder[source]

Build database alter role command to add login and createdb privileges

create_command(db_user: str | None = None) DatabaseCommandBuilder[source]

Build database create command

legacy_init_base_command(*, with_demo: bool = False, without_demo: bool = False, language: str | None = None) DatabaseCommandBuilder[source]

Build legacy-compatible Odoo server init command for base installation.

native_db_init_command(*, with_demo: bool = False, without_demo: bool = False, country: str | None = None, language: str | None = None, username: str = 'admin', password: str = 'admin', force: bool = False) DatabaseCommandBuilder[source]

Build native Odoo 19+ db init command.

init_command(*, with_demo: bool = False, without_demo: bool = False, country: str | None = None, language: str | None = None) DatabaseCommandBuilder[source]

Backward-compatible wrapper for legacy base initialization.

list_db_command(db_user: str | None = None) DatabaseCommandBuilder[source]

Build database list command

exists_db_command(db_user: str | None = None) DatabaseCommandBuilder[source]

Build database exists check command

reset() None[source]

Reset builder to initial state

build() list[str][source]

Build the final command list

build_operation() CommandOperation[source]

Build and return a structured CommandOperation with metadata

Usage Examples

from oduit import ConfigLoader, ProcessManager
from oduit.builders import InstallCommandBuilder, OdooTestCommandBuilder

loader = ConfigLoader()
config = loader.load_config("dev")
manager = ProcessManager()

install_operation = InstallCommandBuilder(config, "sale").build_operation()
install_result = manager.run_operation(install_operation, verbose=True)

test_operation = OdooTestCommandBuilder(config).test_tags("/sale").build_operation()
test_result = manager.run_operation(test_operation)

Key Concepts

  • build() returns a plain command list for compatibility

  • build_operation() returns a structured CommandOperation

  • the structured form carries metadata such as operation type, modules, and parser hints for downstream result processing

  • version-aware i18n flows use dedicated builders: I18nExportCommandBuilder, I18nImportCommandBuilder, and I18nLoadLanguageCommandBuilder