Manifestoo Core
Manifestoo Core is a Python library designed to reason about Odoo addons manifests. It provides functionalities to detect the Odoo series from an addon's version, offer information about core Odoo Community Edition and Enterprise Edition addons for various Odoo versions, and convert Odoo manifest metadata into Python Packaging Metadata. The library is actively maintained with frequent updates, currently at version 1.15.1, often aligned with new Odoo versions and manifest specifications.
Common errors
-
manifestoo_core.addon.AddonNotFound: No valid Odoo addon found in directory
cause The specified directory does not contain a valid Odoo addon (e.g., missing `__manifest__.py` file or it's malformed).fixVerify that the `__manifest__.py` file exists in the directory you are trying to parse and that its content is a valid JSON dictionary as expected by Odoo. Ensure the directory path is correct. -
TypeError: 'version' keyword argument must be a string, not 'NoneType'
cause This error can occur if an Odoo addon manifest is missing the 'version' key, or if `manifestoo-core` is attempting to process an invalid or incomplete manifest.fixEnsure all Odoo addon manifests processed by `manifestoo-core` contain a valid 'version' key with a string value, e.g., `"version": "16.0.1.0.0"`.
Warnings
- breaking Support for Python 3.6 was dropped in `manifestoo-core` v1.9. Users on Python 3.6 will encounter `ModuleNotFoundError` or other compatibility issues.
- gotcha Odoo 19 introduced changes to manifest structures, such as new keys in `external_dependencies` (e.g., `apt`). While `manifestoo-core` v1.13 and newer support these, older versions might not correctly parse Odoo 19 manifests or may yield incomplete data.
- gotcha The `MetadataOptions` class gained an `additional_dependencies` option in v1.15. If you are converting Odoo manifests to Python Packaging Metadata and require custom dependency handling, this option might be relevant.
Install
-
pip install manifestoo-core
Imports
- Addon
from manifestoo_core.addon import Addon
- OdooSeries
from manifestoo_core.odoo_series import OdooSeries
- get_core_addons, is_core_addon, get_core_addon_license
from manifestoo_core.core_addons import get_core_addons, is_core_addon, get_core_addon_license
- metadata_from_addon_dir, MetadataOptions
from manifestoo_core.metadata import metadata_from_addon_dir, MetadataOptions
Quickstart
from pathlib import Path
from manifestoo_core.addon import Addon, AddonNotFound
from manifestoo_core.odoo_series import OdooEdition, OdooSeries
from manifestoo_core.core_addons import get_core_addons, is_core_addon, get_core_addon_license
from manifestoo_core.metadata import metadata_from_addon_dir, MetadataOptions
import os
# Create a dummy addon directory for demonstration
addon_path = Path("./my_test_addon")
addon_path.mkdir(exist_ok=True)
manifest_content = '{"name": "My Test Addon", "version": "16.0.1.0.0", "depends": ["base", "sale"], "license": "LGPL-3"}'
(addon_path / "__manifest__.py").write_text(manifest_content)
# Example 1: Parse an addon manifest
try:
addon = Addon.from_addon_dir(addon_path)
print(f"Addon Name: {addon.name}")
print(f"Addon Version: {addon.version}")
print(f"Detected Odoo Series: {addon.odoo_series}")
print(f"Dependencies: {addon.depends}")
except AddonNotFound:
print(f"No valid Odoo addon found at {addon_path}")
# Example 2: Check core Odoo addons
series = OdooSeries.from_str("16.0")
core_addons = get_core_addons(series, OdooEdition.CE)
print(f"\nSample core CE addons for {series.value}: {list(core_addons)[:3]}")
print(f"'sale' is core for {series.value} CE: {is_core_addon('sale', series, OdooEdition.CE)}")
# Example 3: Generate Python Package Metadata
metadata = metadata_from_addon_dir(addon_path)
print(f"\nGenerated Package Name: {metadata['Name']}")
print(f"Generated Package Version: {metadata['Version']}")
# Clean up dummy addon
(addon_path / "__manifest__.py").unlink()
addon_path.rmdir()