How oca/odoo-module-migrator works
Project type and purpose
• This is a Python-based CLI tool and library—“odoo-module-migrator”—that automates source‐code migrations of Odoo modules from one version to another (e.g. 8.0→12.0).
• It reads an input module directory, applies a series of well-organized migration scripts (renaming files, replacing imports, stripping obsolete patterns), optionally uses Git format-patch to ingest upstream changes, commits results, and logs INFO/WARNING/ERROR messages.
File structure
• Top-level:
• configuration & CI (.github, .travis.yml, pre-commit config)
• setup.py, requirements.txt, license, README
• odoo_module_migrate/ package containing core engine and subpackages
• tests/ verifying migrations against sample modules
• Inside odoo_module_migrate/:
• __main__.py → CLI entrypoint
• config.py → command-line argument parsing
• migration.py + base_migration_script.py → core orchestration and base class
• migration_scripts/ → version‐grouped YAML‐ and Python-based rules (deprecated, removed_fields, renamed_fields, text_replaces, etc.)
• log.py, exception.py → logging & error handling
• tools.py, module_migration.py → low-level file/string replacements and git interactions
• Tests mirror migration scripts and sample Odoo module code before/after.
Insights from README
• The tool chain: CLI→parse args→(optionally) git format-patch→iterate modules→load ordered migration scripts→apply replacements & renames→git add/commit→emit logs.
• Migration scripts are grouped by version ranges, written in YAML or Python, and loaded dynamically.
Elements
• From “User” → “CLI Parser”
• “CLI Parser” → “Core Engine”
• “Core Engine” → “Migration Scripts Loader” → “Migration Script #1” → … → “Migration Script #N” → back to “Core Engine”
• “Core Engine” → “Git Interface” → “File System”
• “Core Engine” → “Logger” → “Console/File”
• Blue rectangles for internal components
• Yellow parallelogram for user input/output (Console)
Detail
• Version-range grouping inside the migration_scripts component