AddonsPathManager

The AddonsPathManager class manages discovery and loading of Odoo modules from addons paths.

class oduit.addons_path_manager.AddonsPathManager(addons_path: str)[source]

Bases: object

Manages discovery and loading of Odoo modules from addons paths.

__init__(addons_path: str)[source]

Initialize AddonsPathManager with comma-separated addons paths.

Parameters:

addons_path – Comma-separated string of addon directory paths

get_all_paths() list[str][source]

Get all addon paths (configured + base Odoo paths).

Returns:

List of all addon paths

get_configured_paths() list[str][source]

Get only configured addon paths (excluding base Odoo paths).

Returns:

List of configured addon paths

get_base_addons_paths() list[str][source]

Get auto-discovered base Odoo addon paths.

find_duplicate_module_names() dict[str, list[str]][source]

Return module names that appear in more than one addons path.

get_collection_from_path(path: str, skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection from a specific addon path.

Parameters:
  • path – Path to addon directory

  • skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing modules from the specified path

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

get_collection_from_paths(paths: list[str], skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection from multiple specific addon paths.

Parameters:
  • paths – List of addon directory paths

  • skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing modules from all specified paths (duplicates are excluded)

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

get_all_collections(skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection from all configured and base addon paths.

Parameters:

skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing all modules from all paths (duplicates are excluded)

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

get_collection_by_filter(filter_dir: str, skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection filtered by directory basename.

Parameters:
  • filter_dir – Directory basename to filter by

  • skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing modules from paths matching filter

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

find_module_path(module_name: str) str | None[source]

Find the absolute path to a module.

Parameters:

module_name – Name of the module to find

Returns:

Absolute path to module directory or None if not found

get_manifest(module_name: str) Manifest | None[source]

Get the manifest for a module.

Parameters:

module_name – Name of the module

Returns:

Manifest instance or None if module not found

get_module_names(filter_dir: str | None = None) list[str][source]

Get sorted list of all module names.

Parameters:

filter_dir – Optional directory basename to filter by

Returns:

Sorted list of module names

Class Reference

class oduit.addons_path_manager.AddonsPathManager(addons_path: str)[source]

Bases: object

Manages discovery and loading of Odoo modules from addons paths.

__init__(addons_path: str)[source]

Initialize AddonsPathManager with comma-separated addons paths.

Parameters:

addons_path – Comma-separated string of addon directory paths

get_all_paths() list[str][source]

Get all addon paths (configured + base Odoo paths).

Returns:

List of all addon paths

get_configured_paths() list[str][source]

Get only configured addon paths (excluding base Odoo paths).

Returns:

List of configured addon paths

get_base_addons_paths() list[str][source]

Get auto-discovered base Odoo addon paths.

find_duplicate_module_names() dict[str, list[str]][source]

Return module names that appear in more than one addons path.

get_collection_from_path(path: str, skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection from a specific addon path.

Parameters:
  • path – Path to addon directory

  • skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing modules from the specified path

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

get_collection_from_paths(paths: list[str], skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection from multiple specific addon paths.

Parameters:
  • paths – List of addon directory paths

  • skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing modules from all specified paths (duplicates are excluded)

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

get_all_collections(skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection from all configured and base addon paths.

Parameters:

skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing all modules from all paths (duplicates are excluded)

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

get_collection_by_filter(filter_dir: str, skip_invalid: bool = False) ManifestCollection[source]

Get ManifestCollection filtered by directory basename.

Parameters:
  • filter_dir – Directory basename to filter by

  • skip_invalid – If True, skip modules with invalid manifests

Returns:

ManifestCollection containing modules from paths matching filter

Raises:

ManifestError – If manifest is invalid and skip_invalid is False

find_module_path(module_name: str) str | None[source]

Find the absolute path to a module.

Parameters:

module_name – Name of the module to find

Returns:

Absolute path to module directory or None if not found

get_manifest(module_name: str) Manifest | None[source]

Get the manifest for a module.

Parameters:

module_name – Name of the module

Returns:

Manifest instance or None if module not found

get_module_names(filter_dir: str | None = None) list[str][source]

Get sorted list of all module names.

Parameters:

filter_dir – Optional directory basename to filter by

Returns:

Sorted list of module names

Usage Examples

Basic Path Management

from oduit.addons_path_manager import AddonsPathManager

# Initialize with comma-separated paths
manager = AddonsPathManager('/path/to/addons1,/path/to/addons2')

# Get all paths (configured + base Odoo paths)
all_paths = manager.get_all_paths()
print(f"All addon paths: {all_paths}")

# Get only configured paths
configured = manager.get_configured_paths()
print(f"Configured paths: {configured}")

Finding Modules

# Find a specific module
module_path = manager.find_module_path('sale')
if module_path:
    print(f"Found sale module at: {module_path}")

# Get manifest for a module
manifest = manager.get_manifest('sale')
if manifest:
    print(f"Sale module version: {manifest.version}")

Working with Collections

# Get collection from specific path
collection = manager.get_collection_from_path('/path/to/addons')
print(f"Found {len(collection)} modules")

# Get all collections from all paths
all_collections = manager.get_all_collections()

# Filter by directory
filtered = manager.get_collection_by_filter('myaddons')
for module_name in filtered:
    print(f"Module: {module_name}")

# Get module names
module_names = manager.get_module_names()
print(f"All modules: {module_names}")

# Get module names from specific directory
custom_modules = manager.get_module_names(filter_dir='myaddons')
print(f"Custom modules: {custom_modules}")