Skip to main content

Small tools to migrate Odoo modules from a version to another

Project description

License: AGPL-3 Python support: 3.6 https://app.travis-ci.com/OCA/odoo-module-migrator.svg?branch=master

odoo-module-migrator

odoo-module-migrator is a python3 library that allows you to automatically migrate module code to make it compatible with newer Odoo versions. For example:

  • renaming __openerp__.py file to __manifest__.py

  • removing # -*- encoding: utf-8 -*- since V11.0

  • replacing openerp import with odoo import

  • removing migrations folders

  • changing <act_window> to <record model=”ir.actions.window”>

This library will:

  • (optionally) get commits from the old branch (if format-patch is enabled)

  • automatically apply changes (renaming, replacing, etc.)

  • commit your changes

  • display warnings or errors in the log if your code contains obsolete code patterns

This project is about migrating code. If you’re looking for database data migration between Odoo versions, check out the https://github.com/OCA/OpenUpgrade project.

INFO log

Indicates that the library automatically changed something. A priori you have nothing to do. For example, for a migration from 8.0 to a more recent version:

12:38:54 INFO Renaming file: '/my_module/__openerp__.py' to '/my_module/__manifest__.py'

WARNING log

Indicates that you should check something. There may be something to do to make the module work. For example:

19:37:55 WARNING Replaced dependency of 'account_analytic_analysis' with 'contract' (Moved to OCA/contract)

ERROR log

Indicates that you must change something in your code. If not, the module will not work for sure (not installable or generating errors during execution).

For example, if you have an 8.0 module that depends on ‘account_anglo_saxon’, which disappeared in more recent versions, the following log will be displayed:

12:38:54 ERROR Depends on removed module 'account_anglo_saxon'

Development and Improvement

If you want to improve or contribute to this library, please read the DEVELOP.rst file and the ‘Roadmap / Known Issues’ sections.

Installation

pip3 install odoo-module-migrator

Usage

Using Format Patch command

(Recommended by the OCA)

If you want to migrate an Odoo module from version 8.0 to 12.0, for example, the module pos_order_pricelist_change in the OCA “pos” repository:

git clone https://github.com/OCA/pos -b 12.0
cd pos
odoo-module-migrate
    --directory             ./
    --modules               pos_order_pricelist_change
    --init-version-name     8.0
    --target-version-name   12.0
    --format-patch

Without format Patch command

(Mainly for your custom modules)

If you have created a new branch (for example 12.0) based on your 10.0 branch, you can run the following command:

odoo-module-migrate
    --directory             /path/to/repository
    --modules               module_1,module_2,module_3
    --init-version-name     10.0
    --target-version-name   12.0

This tool will operate the changes for each module.

Available Arguments

Name

Shortcut

Options

Description

--directory

-d

Default: ./

Local folder that contains the module(s) to migrate.

--init-version-name

-i

Required

Initial version of your module(s) you want to migrate.

--target-version-name

-t

Default: the latest Odoo version

Final version you want to migrate to.

--modules

-m

Default: All modules in the directory

Module(s) to migrate. Note: if the format-patch option is enabled, you have to provide only one module.

--format-patch

-fp

Disabled by default

Recover code using the git format-patch command.

--remote-name

-rn

Default: origin

Name of the main remote used by the format-patch command.

--log-level

-ll

Default: INFO

Possible values: DEBUG, INFO, WARNING, etc.

--log-path

-lp

Default: False

If set, logs will not be displayed on screen, but stored in a file.

--no-commit

-nc

Default: commit

If set, the library will not git add and git commit changes.

Roadmap / Known Issues

  • The replacement of the tag <openerp><data> with <odoo> will fail in cases where there are many <data> occurrences. We could fix that by using the lxml library instead of regular expressions.

  • Add a call to pre-commit run -a, if pre-commit is present in the repository.

Changes

0.3.2 (December 04, 2019)

  • [REM] Remove black call (add call to a more generic tool pre-commit in the roadmap).

  • [IMP] Add –no-verify option in git commit to avoid failure if pre-commit is present.

  • [REF] Refactor _execute_shell function.

0.2.0 (October 13, 2019)

  • Second release.

0.1.4 (October 12, 2019)

  • Test

[ADD] test.

  • Framework

[ADD] --file-path option. [ADD] _DEPRECATED_MODULES syntax.

  • Migration script

[FIX] Incorrect syntax of regular expression to remove python 2 header. [IMP] First release of all the steps from 8.0 to 13.0.

0.1.3 (October 11, 2019)

  • Framework

[ADD] --no-commit option that disables git add and git commit calls. [FIX] Do not commit many times if migration has many steps. [REF] Remove useless commented code. [REF] Create _commit_changes() and _replace_in_file() functions.

  • Meta

[FIX] GitHub URL of the project in setup.py. [ADD] Travis file + links to coveralls. [ADD] test_requirements.txt.

  • Migration script

[ADD] Migration from 12.0 to 13.0 and add a warning if references to web_settings_dashboard are found, courtesy of @yelizariev. [ADD] Bump version in manifest file. [ADD] Set installable to True.

0.1.2 (October 10, 2019)

  • First release.

Credits

Authors

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

odoo_module_migrator-0.5.0.tar.gz (45.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odoo_module_migrator-0.5.0-py3-none-any.whl (59.4 kB view details)

Uploaded Python 3

File details

Details for the file odoo_module_migrator-0.5.0.tar.gz.

File metadata

  • Download URL: odoo_module_migrator-0.5.0.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for odoo_module_migrator-0.5.0.tar.gz
Algorithm Hash digest
SHA256 6624f17cf0d3dbe6212fdffad2b95bf3fcd780f61bc6208e1c60b99ede68e433
MD5 ea91a228833b24800047d524561c763f
BLAKE2b-256 58ecfe98d2f96b29070ad9ab7d6b9063200c95473218a840cb22baaa5d731a92

See more details on using hashes here.

Provenance

The following attestation bundles were made for odoo_module_migrator-0.5.0.tar.gz:

Publisher: release.yml on OCA/odoo-module-migrator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file odoo_module_migrator-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_module_migrator-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ace73ab960efded79e5c39b46fa988f012047524661a16ca97eaa47d71480b9d
MD5 30674b85f8b8073585f765b153b52d8d
BLAKE2b-256 c0b119b6761503ff29d704b9653a5fc675b7355d60300a61c96b574fbe8ffe50

See more details on using hashes here.

Provenance

The following attestation bundles were made for odoo_module_migrator-0.5.0-py3-none-any.whl:

Publisher: release.yml on OCA/odoo-module-migrator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page