You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
5.6KB

  1. Installation
  2. ============
  3. .. code-block:: shell
  4. # Pull Code
  5. git clone https://github.com/grap/odoo-module-migrator
  6. cd odoo-module-migrator
  7. # Create virtual env and activate it
  8. virtualenv env --python=python3
  9. . ./env/bin/activate
  10. # Install dependencies
  11. pip3 install -r requirements.txt
  12. # Run the script
  13. python -m odoo_module_migrate COMMAND OPTIONS
  14. You can also install from test source via pip:
  15. .. code-block:: shell
  16. pip3 install odoo-module-migrator\
  17. --upgrade\
  18. --index-url https://test.pypi.org/simple\
  19. --extra-index-url https://pypi.org/simple
  20. Run tests
  21. =========
  22. .. code-block:: shell
  23. # Activate virtual env
  24. . ./env/bin/activate
  25. # Install extra dependencies required for tests
  26. pip3 install -r test_requirements.txt
  27. # Run Tests
  28. coverage run --source odoo_module_migrate setup.py test
  29. Structure of the Project
  30. ========================
  31. Framework
  32. ---------
  33. In the ``odoo_module_migrate`` folder
  34. * ``__main__.py``: the entry point of this module. It mainly
  35. handles arguments, and launch the script.
  36. * ``config.py``: configuration file, to updated if new features are available
  37. in this library. (For exemple, a new migration available from X to X+1)
  38. * ``log.py``: Handle logs of this library.
  39. * ``tools.py``: bundle of generic functions used by the framework.
  40. * ``migration.py``: Define the class ``Migration`` that handle a migration
  41. from a version X.0 to a version Y.0 for any module.
  42. * ``module_migration.py``: Define the class ``ModuleMigration`` that handle
  43. a migration for a given module.
  44. Migration Scripts
  45. -----------------
  46. The list of the operations are written in the subfolder
  47. `<odoo_module_migrate/migration_scripts/>`__:
  48. * each operaion has specification when it has to be applied: ``FROM_TO`` part of the path.
  49. * `Possible values are <odoo_module_migrate/config.py>`__ ``090``, ``010``, ``011``, etc.
  50. * The ``TO`` part may have value ``always``, which means is should be applied in every version since ``FROM`` version.
  51. * Special value for ``FROM_TO`` is just a single ``allways`` (yes, it's mispealing) which means it will be applied whatever the init and target odoo version.
  52. * ``migrate_FROM_TO.py`` — old way to specify operations. Normally, these files should not be changed.
  53. * ``file_renames/migrate_FROM_TO/NAME.yaml`` — file renaming rules. For
  54. example, for migration from version 8.0 to more recent version:
  55. .. code-block:: yaml
  56. __openerp__.py: __manifest__.py
  57. * ``text_replaces/migrate_FROM_TO/NAME.yaml`` — replace pattern text by
  58. another. for example, for migration from version 8.0 to version 9.0:
  59. .. code-block:: yaml
  60. .py:
  61. select=True: index=True
  62. * ``text_errors/migrate_FROM_TO/NAME.yaml`` — display errors if files contains a
  63. given partern. For example, for migration from version 10.0 to version 11.0:
  64. .. code-block:: yaml
  65. "*":
  66. ir.values: "ir.values table does not exist anymore"
  67. * ``text_warnings/migrate_FROM_TO/NAME.yaml`` — display errors if files contains a
  68. given partern. For example, for migration from version 12.0 to version 13.0:
  69. .. code-block:: yaml
  70. "*":
  71. "@api.returns": "decorator @api.returns is deprecated"
  72. * ``deprecated_modules/migrate_FROM_TO/NAME.yaml`` — dependencies to obsoletes modules. There are following possibilities:
  73. * the module has been fully removed.
  74. * the module has been renamed.
  75. * the module features has been merged into another module.
  76. * the module has been moved under OCA umbrella. (w/o another name)
  77. .. code-block:: yaml
  78. - ["account_anglo_saxon", "removed"]
  79. - ["account_check_writing", "renamed", "account_check_printing"]
  80. - ["account_chart", "merged", "account"]
  81. - ["account_analytic_analysis", "oca_moved", "contract", "Moved to OCA/contract"]
  82. * ``python_scripts/migrate_FROM_TO/NAME.py`` — for complex updates/checks. Must contain one or few functions that don't start with underscore symbol. The functions take following keyword arguments:
  83. * ``logger``
  84. * ``module_path``
  85. * ``module_name``
  86. * ``manifest_path``
  87. * ``migration_steps`` — list of steps. See ``_AVAILABLE_MIGRATION_STEPS`` in `<odoo_module_migrate/config.py>`__
  88. * ``tools`` — python module with some functions. See `<odoo_module_migrate/tools.py>`__
  89. .. code-block:: py
  90. def set_module_installable(**kwargs):
  91. tools = kwargs['tools']
  92. manifest_path = kwargs['manifest_path']
  93. old_term = r"('|\")installable('|\").*(False)"
  94. new_term = r"\1installable\2: True"
  95. tools._replace_in_file(
  96. manifest_path, {old_term: new_term}, "Set module installable")
  97. How to improve the library
  98. ==========================
  99. * Read (or complete !) the migration advices of the OCA.
  100. https://github.com/OCA/maintainer-tools/wiki#migration
  101. * Read the complementary pages
  102. https://odoo-development.readthedocs.io/en/latest/migration/
  103. * Discover what changed between two revisions, reading OpenUpgrade
  104. documentation, specially the modules changes, for exemple:
  105. https://github.com/OCA/OpenUpgrade/blob/12.0/odoo/openupgrade/doc/source/modules110-120.rst
  106. * Create or complete the according migration file.
  107. * Add tests.
  108. * Make a Pull request.
  109. Package deployment
  110. ==================
  111. .. code-block:: shell
  112. pip3 install --upgrade setuptools wheel
  113. pip3 install --upgrade twine
  114. # Generate wheel and package
  115. python3 setup.py sdist bdist_wheel
  116. # Push on pyPi Test
  117. twine upload --repository-url https://test.pypi.org/legacy/ dist/*
  118. # Push on pyPi Production
  119. twine upload dist/*
上海开阖软件有限公司 沪ICP备12045867号-1