odoo-module-migrator


Nameodoo-module-migrator JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/OCA/odoo-module-migrator
SummarySmall tools to migrate Odoo modules from a version to another
upload_time2025-08-21 18:30:45
maintainerNone
docs_urlNone
authorGRAP, Groupement Régional Alimentaire de Proximité
requires_pythonNone
licenseNone
keywords odoo community association (oca) odoo migration upgrade module
VCS
bugtrack_url
requirements argcomplete colorama lxml pyyaml
Travis-CI
coveralls test coverage No coveralls.
            .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. image:: https://img.shields.io/badge/python-3.6-blue.svg
    :alt: Python support: 3.6
.. image:: https://app.travis-ci.com/OCA/odoo-module-migrator.svg?branch=master
    :target: https://app.travis-ci.com/OCA/odoo-module-migrator

====================
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:

.. code-block:: shell

    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:

.. code-block:: shell

    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:

.. code-block:: shell

    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
============

.. code-block:: shell

    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:

.. code-block:: shell

    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:

.. code-block:: shell

    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:        | Final version you want to migrate to.                 |
|                          |          | the latest Odoo |                                                       |
|                          |          | version         |                                                       |
+--------------------------+----------+-----------------+-------------------------------------------------------+
|``--modules``             | ``-m``   | Default:        | Module(s) to migrate. Note: if the format-patch option|
|                          |          | All modules     | is enabled, you have to provide only one module.      |
|                          |          | in the          |                                                       |
|                          |          | directory       |                                                       |
+--------------------------+----------+-----------------+-------------------------------------------------------+
|``--format-patch``        | ``-fp``  | Disabled        | Recover code using the git format-patch command.      |
|                          |          | by default      |                                                       |
+--------------------------+----------+-----------------+-------------------------------------------------------+
|``--remote-name``         | ``-rn``  | Default:        | Name of the main remote used by the format-patch      |
|                          |          | ``origin``      | command.                                              |
+--------------------------+----------+-----------------+-------------------------------------------------------+
|``--log-level``           | ``-ll``  | Default:        | Possible values: ``DEBUG``, ``INFO``, ``WARNING``,    |
|                          |          | ``INFO``        | etc.                                                  |
+--------------------------+----------+-----------------+-------------------------------------------------------+
|``--log-path``            | ``-lp``  | Default:        | If set, logs will not be displayed on screen,         |
|                          |          | False           | but stored in a file.                                 |
+--------------------------+----------+-----------------+-------------------------------------------------------+
|``--no-commit``           | ``-nc``  | Default:        | If set, the library will not git add and git commit   |
|                          |          | 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
-------

* GRAP, Groupement Régional Alimentaire de Proximité (http://www.grap.coop)

Contributors
------------

* Sylvain LE GAL (https://www.twitter.com/legalsylvain)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/OCA/odoo-module-migrator",
    "name": "odoo-module-migrator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "Odoo Community Association (OCA), Odoo, Migration, Upgrade, Module",
    "author": "GRAP, Groupement R\u00e9gional Alimentaire de Proximit\u00e9",
    "author_email": "informatique@grap.coop",
    "download_url": "https://files.pythonhosted.org/packages/58/ec/fe98d2f96b29070ad9ab7d6b9063200c95473218a840cb22baaa5d731a92/odoo_module_migrator-0.5.0.tar.gz",
    "platform": null,
    "description": ".. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg\n    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html\n    :alt: License: AGPL-3\n.. image:: https://img.shields.io/badge/python-3.6-blue.svg\n    :alt: Python support: 3.6\n.. image:: https://app.travis-ci.com/OCA/odoo-module-migrator.svg?branch=master\n    :target: https://app.travis-ci.com/OCA/odoo-module-migrator\n\n====================\nodoo-module-migrator\n====================\n\n``odoo-module-migrator`` is a python3 library that allows you to automatically migrate\nmodule code to make it compatible with newer Odoo versions.\nFor example:\n\n* renaming ``__openerp__.py`` file to ``__manifest__.py``\n* removing ``# -*- encoding: utf-8 -*-`` since V11.0\n* replacing ``openerp`` import with ``odoo`` import\n* removing ``migrations`` folders\n* changing <act_window> to <record model=\"ir.actions.window\">\n* ...\n\nThis library will:\n\n* (optionally) get commits from the old branch (if format-patch is enabled)\n* automatically apply changes (renaming, replacing, etc.)\n* commit your changes\n* display warnings or errors in the log if your code contains obsolete code patterns\n\nThis project is about migrating code. If you're looking for database data migration\nbetween Odoo versions, check out the https://github.com/OCA/OpenUpgrade project.\n\n**INFO log**\n\nIndicates that the library automatically changed something.\n*A priori* you have nothing to do. For example, for a migration from 8.0 to\na more recent version:\n\n.. code-block:: shell\n\n    12:38:54 INFO Renaming file: '/my_module/__openerp__.py' to '/my_module/__manifest__.py'\n\n**WARNING log**\n\nIndicates that you should check something. There may be something to do\nto make the module work. For example:\n\n.. code-block:: shell\n\n    19:37:55 WARNING Replaced dependency of 'account_analytic_analysis' with 'contract' (Moved to OCA/contract)\n\n**ERROR log**\n\nIndicates that you must change something in your code. If not, the module\nwill not work *for sure* (not installable or generating errors during\nexecution).\n\nFor example, if you have an 8.0 module that depends on 'account_anglo_saxon',\nwhich disappeared in more recent versions, the following log will be displayed:\n\n.. code-block:: shell\n\n    12:38:54 ERROR Depends on removed module 'account_anglo_saxon'\n\nDevelopment and Improvement\n===========================\n\nIf you want to improve or contribute to this library, please read the\n``DEVELOP.rst`` file and the 'Roadmap / Known Issues' sections.\n\nInstallation\n============\n\n.. code-block:: shell\n\n    pip3 install odoo-module-migrator\n\nUsage\n=====\n\nUsing Format Patch command\n--------------------------\n\n(Recommended by the OCA)\n\nIf you want to migrate an Odoo module from version 8.0 to 12.0, for example,\nthe module ``pos_order_pricelist_change`` in the OCA \"pos\" repository:\n\n.. code-block:: shell\n\n    git clone https://github.com/OCA/pos -b 12.0\n    cd pos\n    odoo-module-migrate\n        --directory             ./\n        --modules               pos_order_pricelist_change\n        --init-version-name     8.0\n        --target-version-name   12.0\n        --format-patch\n\nWithout format Patch command\n----------------------------\n\n(Mainly for your custom modules)\n\nIf you have created a new branch (for example 12.0) based on your 10.0 branch,\nyou can run the following command:\n\n.. code-block:: shell\n\n    odoo-module-migrate\n        --directory             /path/to/repository\n        --modules               module_1,module_2,module_3\n        --init-version-name     10.0\n        --target-version-name   12.0\n\nThis tool will operate the changes for each module.\n\nAvailable Arguments\n-------------------\n\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n| Name                     | Shortcut | Options         | Description                                           |\n+==========================+==========+=================+=======================================================+\n|``--directory``           | ``-d``   | Default:        | Local folder that contains the module(s) to migrate.  |\n|                          |          | ``./``          |                                                       |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--init-version-name``   | ``-i``   | Required        | Initial version of your module(s) you want to migrate.|\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--target-version-name`` | ``-t``   | Default:        | Final version you want to migrate to.                 |\n|                          |          | the latest Odoo |                                                       |\n|                          |          | version         |                                                       |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--modules``             | ``-m``   | Default:        | Module(s) to migrate. Note: if the format-patch option|\n|                          |          | All modules     | is enabled, you have to provide only one module.      |\n|                          |          | in the          |                                                       |\n|                          |          | directory       |                                                       |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--format-patch``        | ``-fp``  | Disabled        | Recover code using the git format-patch command.      |\n|                          |          | by default      |                                                       |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--remote-name``         | ``-rn``  | Default:        | Name of the main remote used by the format-patch      |\n|                          |          | ``origin``      | command.                                              |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--log-level``           | ``-ll``  | Default:        | Possible values: ``DEBUG``, ``INFO``, ``WARNING``,    |\n|                          |          | ``INFO``        | etc.                                                  |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--log-path``            | ``-lp``  | Default:        | If set, logs will not be displayed on screen,         |\n|                          |          | False           | but stored in a file.                                 |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n|``--no-commit``           | ``-nc``  | Default:        | If set, the library will not git add and git commit   |\n|                          |          | commit          | changes.                                              |\n+--------------------------+----------+-----------------+-------------------------------------------------------+\n\nRoadmap / Known Issues\n======================\n\n* The replacement of the tag <openerp><data> with <odoo> will fail in cases\n  where there are many <data> occurrences.\n  We could fix that by using the ``lxml`` library instead of regular expressions.\n\n* Add a call to ``pre-commit run -a``, if pre-commit is present in the\n  repository.\n\nChanges\n=======\n\n0.3.2 (December 04, 2019)\n-------------------------\n* [REM] Remove black call (add call to a more generic tool pre-commit\n  in the roadmap).\n* [IMP] Add --no-verify option in ``git commit`` to avoid failure if pre-commit\n  is present.\n* [REF] Refactor ``_execute_shell`` function.\n\n0.2.0 (October 13, 2019)\n------------------------\n* Second release.\n\n0.1.4 (October 12, 2019)\n------------------------\n* Test\n\n[ADD] test.\n\n* Framework\n\n[ADD] ``--file-path`` option.\n[ADD] ``_DEPRECATED_MODULES`` syntax.\n\n* Migration script\n\n[FIX] Incorrect syntax of regular expression to remove python 2 header.\n[IMP] First release of all the steps from 8.0 to 13.0.\n\n0.1.3 (October 11, 2019)\n------------------------\n\n* Framework\n\n[ADD] ``--no-commit`` option that disables git add and git commit calls.\n[FIX] Do not commit many times if migration has many steps.\n[REF] Remove useless commented code.\n[REF] Create ``_commit_changes()`` and ``_replace_in_file()`` functions.\n\n* Meta\n\n[FIX] GitHub URL of the project in setup.py.\n[ADD] Travis file + links to coveralls.\n[ADD] test_requirements.txt.\n\n* Migration script\n\n[ADD] Migration from 12.0 to 13.0 and add a warning if references to web_settings_dashboard are found, courtesy of @yelizariev.\n[ADD] Bump version in manifest file.\n[ADD] Set installable to True.\n\n0.1.2 (October 10, 2019)\n------------------------\n\n* First release.\n\nCredits\n=======\n\nAuthors\n-------\n\n* GRAP, Groupement R\u00e9gional Alimentaire de Proximit\u00e9 (http://www.grap.coop)\n\nContributors\n------------\n\n* Sylvain LE GAL (https://www.twitter.com/legalsylvain)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Small tools to migrate Odoo modules from a version to another",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://github.com/OCA/odoo-module-migrator"
    },
    "split_keywords": [
        "odoo community association (oca)",
        " odoo",
        " migration",
        " upgrade",
        " module"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c0b119b6761503ff29d704b9653a5fc675b7355d60300a61c96b574fbe8ffe50",
                "md5": "30674b85f8b8073585f765b153b52d8d",
                "sha256": "ace73ab960efded79e5c39b46fa988f012047524661a16ca97eaa47d71480b9d"
            },
            "downloads": -1,
            "filename": "odoo_module_migrator-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "30674b85f8b8073585f765b153b52d8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 59410,
            "upload_time": "2025-08-21T18:30:44",
            "upload_time_iso_8601": "2025-08-21T18:30:44.517888Z",
            "url": "https://files.pythonhosted.org/packages/c0/b1/19b6761503ff29d704b9653a5fc675b7355d60300a61c96b574fbe8ffe50/odoo_module_migrator-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "58ecfe98d2f96b29070ad9ab7d6b9063200c95473218a840cb22baaa5d731a92",
                "md5": "ea91a228833b24800047d524561c763f",
                "sha256": "6624f17cf0d3dbe6212fdffad2b95bf3fcd780f61bc6208e1c60b99ede68e433"
            },
            "downloads": -1,
            "filename": "odoo_module_migrator-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ea91a228833b24800047d524561c763f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 45243,
            "upload_time": "2025-08-21T18:30:45",
            "upload_time_iso_8601": "2025-08-21T18:30:45.828430Z",
            "url": "https://files.pythonhosted.org/packages/58/ec/fe98d2f96b29070ad9ab7d6b9063200c95473218a840cb22baaa5d731a92/odoo_module_migrator-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-21 18:30:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "OCA",
    "github_project": "odoo-module-migrator",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "argcomplete",
            "specs": []
        },
        {
            "name": "colorama",
            "specs": []
        },
        {
            "name": "lxml",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": []
        }
    ],
    "test_requirements": [
        {
            "name": "coveralls",
            "specs": []
        },
        {
            "name": "flake8",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        }
    ],
    "lcname": "odoo-module-migrator"
}
        
Elapsed time: 1.90680s