Skip to content

Latest commit

 

History

History
170 lines (111 loc) · 4.27 KB

DEVELOP.rst

File metadata and controls

170 lines (111 loc) · 4.27 KB

Installation

# Pull Code
git clone https://github.com/grap/odoo-module-migrator
cd odoo-module-migrator

# Create virtual env and activate it
virtualenv env --python=python3
. ./env/bin/activate

# Install dependencies
pip3 install -r requirements.txt

# Run the script
python -m odoo_module_migrate COMMAND OPTIONS

You can also install from test source via pip:

pip3 install odoo-module-migrator\
    --upgrade\
    --index-url https://test.pypi.org/simple\
    --extra-index-url https://pypi.org/simple

Run tests

# Activate virtual env
. ./env/bin/activate

# Install extra dependencies required for tests
pip3 install -r test_requirements.txt

# Run Tests
coverage run --source odoo_module_migrate setup.py test

Structure of the Project

Framework

In the odoo_module_migrate folder

  • __main__.py: the entry point of this module. It mainly handles arguments, and launch the script.
  • config.py: configuration file, to updated if new features are available in this library. (For exemple, a new migration available from X to X+1)
  • log.py: Handle logs of this library.
  • tools.py: bundle of generic functions used by the framework.
  • migration.py: Define the class Migration that handle a migration from a version X.0 to a version Y.0 for any module.
  • module_migration.py: Define the class ModuleMigration that handle a migration for a given module.

Migration Scripts

The list of the operations are written in the subfolder odoo_module_migrate/migration_scripts:

  • in a file for each migration for exemple migrate_090__100.py file contains all the operations to do for a migration from 9.0 to 10.0.
  • in a file for operations that should be execute since some revision, named for exemple migrate_10_0__allways.py
  • a file migrate_allways.py contains all the operations that will be executed, whatever the init and the target versions.

List of the operations

  • Rename files. For exemple, for migration from version 8.0 to more recent version
_FILE_RENAMES = {
    "__openerp__.py": "__manifest__.py",
}
  • Replace pattern text by another. for exemple, for migration from version 8.0 to version 9.0:
_TEXT_REPLACES = {
     ".py": {
         "select=True": "index=True",
     }
 }
  • Display errors if files contains a given partern. For exemple, for migration from version 10.0 to version 11.0:
_TEXT_ERRORS = {
    "*": {
        "ir.values": "ir.values table does not exist anymore"
    }
}
  • Dependencies to obsoletes modules. There is four possibility:
    • the module has been fully removed.
    • the module has been renamed.
    • the module features has been merged into another module.
    • the module has been moved under OCA umbrella. (w/o another name)
_DEPRECATED_MODULES = [

    ("account_anglo_saxon", "removed"),

    ("account_check_writing", "renamed", "account_check_printing"),

    ("account_chart", "merged", "account"),

    ("account_analytic_analysis", "oca_moved", "contract", "Moved to OCA/contract"),

]

How to improve the library

Package deployment

pip3 install --upgrade setuptools wheel
pip3 install  --upgrade twine

# Generate wheel and package
python3 setup.py sdist bdist_wheel

# Push on pyPi Test
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

# Push on pyPi Production
twine upload dist/*