diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf8470221c88..01e721f2268c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,8 @@ name: Test OpenUpgrade migration on: push: - branches: ["18.0*"] + branches: ["17.0*"] + pull_request: jobs: test: @@ -90,9 +91,11 @@ jobs: pip install asn1crypto - name: Test data run: | - for snippet in openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py; do - odoo-old/odoo-bin shell -d $DB < $snippet - done + if test -n "$(ls openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py 2> /dev/null)"; then + for snippet in openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py; do + odoo-old/odoo-bin shell -d $DB < $snippet + done + fi - name: OpenUpgrade test run: | # select modules and perform the upgrade diff --git a/build_openupgrade_docs b/build_openupgrade_docs index aeafb7715603..a4cc810fafa0 100644 --- a/build_openupgrade_docs +++ b/build_openupgrade_docs @@ -15,6 +15,7 @@ DOC_PARTS="7.0/openerp/openupgrade/doc/source/modules50-60.rst 14.0/docsource/modules130-140.rst 15.0/docsource/modules140-150.rst 16.0/docsource/modules150-160.rst +17.0/docsource/modules160-170.rst " OUTPUT_DIR=${OUTPUT_DIR:-$DOC_BUILD_DIR} diff --git a/openupgrade_framework/README.rst b/openupgrade_framework/README.rst new file mode 100644 index 000000000000..265feae7b0ca --- /dev/null +++ b/openupgrade_framework/README.rst @@ -0,0 +1,205 @@ +===================== +Openupgrade Framework +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:06d77ecf97625ec075fa31dde7f8f41bcf849fa13af0598f8c1de397348f2dfd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2FOpenUpgrade-lightgray.png?logo=github + :target: https://github.com/OCA/OpenUpgrade/tree/17.0/openupgrade_framework + :alt: OCA/OpenUpgrade +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/OpenUpgrade-17-0/OpenUpgrade-17-0-openupgrade_framework + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/OpenUpgrade&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module is a technical module that contains a number of monkeypatches +to improve the behaviour of Odoo when migrating your database using the +OpenUpgrade migration scripts: + +* Prevent dropping columns or tables in the database when fields or models + are obsoleted in the Odoo data model of the target release. After the + migration, you can review and delete unused database tables and columns + using `database_cleanup`. See + https://odoo-community.org/shop/product/database-cleanup-918 +* When data records are deleted during the migration (such as views or other + system records), this is done in a secure mode. If the deletion fails because + of some unforeseen dependency, the deletion will be cancelled and a message + is logged, after which the migration continues. +* Prevent a number of log messages that do not apply when using OpenUpgrade. +* Suppress log messages about failed view validation, which are to be expected + during a migration. +* Run migration scripts for modules that are installed as new dependencies + of upgraded modules (when there are such scripts for those particular + modules) +* Production databases generated with demo data, will be transformed to + non-demo ones. If you want to avoid that, you have to pass through the + environment variable OPENUPGRADE_USE_DEMO, the value "yes". + +For detailed documentation see: + +* https://github.com/OCA/OpenUpgrade/ +* https://oca.github.io/OpenUpgrade + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module does not need to be installed on a database. +It simply needs to be available via your ``addons-path``. + +Configuration +============= + +* call your odoo instance with the option ``--load=base,web,openupgrade_framework`` + +or + +* add the key to your configuration file: + +.. code-block:: shell + + [options] + server_wide_modules = web,openupgrade_framework + +When you load the module in either way of these ways, and you have the +`openupgrade_scripts` module in your addons path available, the +`--upgrade-path` option of Odoo will be set automatically to the location +of the OpenUpgrade migration scripts. + +Development +=========== + +The `odoo_patch` folder contains python files in a tree that mimicks the +folder tree of the Odoo project. It contains a number of monkey patches +to improve the migration of an Odoo database between two major versions. + +So far, we are able to make everything work without overwriting large blocks +of code, but if larger patches need to be added, please use the method +described below: + +To see the patches added, you can use ``meld`` tools: + +``meld PATH_TO_ODOO_FOLDER/odoo/ PATH_TO_OPENUPGRADE_FRAMEWORK_MODULE/odoo_patch`` + + +To make more easy the diff analysis : + +* Make sure the python files has the same path as the original one. + +* Keep the same indentation as the original file. (using ``if True:`` if required) + +* Add the following two lines at the beginning of your file, to avoid flake8 / pylint + errors + +.. code-block:: python + + # flake8: noqa + # pylint: skip-file + +* When you want to change the code. add the following tags: + +For an addition: + +.. code-block:: python + + # + some code... + # + +For a change: + +.. code-block:: python + + # + some code... + # + +For a removal: + +.. code-block:: python + + # + # Comment the code, instead of removing it. + # + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Therp BV +* Opener B.V. +* GRAP + +Contributors +~~~~~~~~~~~~ + +* Stefan Rijnhart +* Sylvain LE GAL + +Other credits +~~~~~~~~~~~~~ + +Many developers have contributed to the OpenUpgrade framework in its previous +incarnation. Their original contributions may no longer needed, or they are +no longer recognizable in their current form but OpenUpgrade would not have +existed at this point without them. + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain +.. |maintainer-StefanRijnhart| image:: https://github.com/StefanRijnhart.png?size=40px + :target: https://github.com/StefanRijnhart + :alt: StefanRijnhart + +Current `maintainers `__: + +|maintainer-legalsylvain| |maintainer-StefanRijnhart| + +This module is part of the `OCA/OpenUpgrade `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/openupgrade_framework/__init__.py b/openupgrade_framework/__init__.py new file mode 100644 index 000000000000..e3b93cdf5f45 --- /dev/null +++ b/openupgrade_framework/__init__.py @@ -0,0 +1,16 @@ +import logging +import os + +from odoo.modules import get_module_path +from odoo.tools import config + +from . import odoo_patch + +if not config.get("upgrade_path"): + path = get_module_path("openupgrade_scripts", display_warning=False) + if path: + logging.getLogger(__name__).info( + "Setting upgrade_path to the scripts directory inside the module " + "location of openupgrade_scripts" + ) + config["upgrade_path"] = os.path.join(path, "scripts") diff --git a/openupgrade_framework/__manifest__.py b/openupgrade_framework/__manifest__.py new file mode 100644 index 000000000000..4e140b277f4f --- /dev/null +++ b/openupgrade_framework/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Openupgrade Framework", + "summary": """Module to integrate in the server_wide_modules + option to make upgrades between two major revisions.""", + "author": "Odoo Community Association (OCA), Therp BV, Opener B.V., GRAP, " + "Hunki Enterprises BV", + "maintainers": ["legalsylvain", "StefanRijnhart", "hbrunn"], + "website": "https://github.com/OCA/OpenUpgrade", + "category": "Migration", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "depends": ["base"], + "images": ["static/description/banner.jpg"], + "external_dependencies": {"python": ["openupgradelib"]}, + "installable": True, +} diff --git a/openupgrade_framework/odoo_patch/__init__.py b/openupgrade_framework/odoo_patch/__init__.py new file mode 100644 index 000000000000..3c691cd11703 --- /dev/null +++ b/openupgrade_framework/odoo_patch/__init__.py @@ -0,0 +1 @@ +from . import odoo diff --git a/openupgrade_framework/odoo_patch/odoo/__init__.py b/openupgrade_framework/odoo_patch/odoo/__init__.py new file mode 100644 index 000000000000..64a54f17e628 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/__init__.py @@ -0,0 +1 @@ +from . import addons, api, models, modules diff --git a/openupgrade_framework/odoo_patch/odoo/addons/__init__.py b/openupgrade_framework/odoo_patch/odoo/addons/__init__.py new file mode 100644 index 000000000000..0e44449338cf --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/__init__.py @@ -0,0 +1 @@ +from . import base diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/__init__.py b/openupgrade_framework/odoo_patch/odoo/addons/base/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/models/__init__.py b/openupgrade_framework/odoo_patch/odoo/addons/base/models/__init__.py new file mode 100644 index 000000000000..9368777a039d --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/__init__.py @@ -0,0 +1,2 @@ +from . import ir_model +from . import ir_ui_view diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py new file mode 100644 index 000000000000..1185d8c0b027 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py @@ -0,0 +1,89 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + +from odoo import api, models + +from odoo.addons.base.models.ir_model import ( + IrModel, + IrModelData, + IrModelFields, + IrModelRelation, + IrModelSelection, +) + + +def _drop_table(self): + """Never drop tables""" + for model in self: + if self.env.get(model.model) is not None: + openupgrade.message( + self.env.cr, + "Unknown", + False, + False, + "Not dropping the table or view of model %s", + model.model, + ) + + +IrModel._drop_table = _drop_table + + +def _drop_column(self): + """Never drop columns""" + for field in self: + if field.name in models.MAGIC_COLUMNS: + continue + openupgrade.message( + self.env.cr, + "Unknown", + False, + False, + "Not dropping the column of field %s of model %s", + field.name, + field.model, + ) + continue + + +IrModelFields._drop_column = _drop_column + + +@api.model +def _module_data_uninstall(self, modules_to_remove): + """To pass context, that the patch in __getitem__ of api.Environment uses""" + patched_self = self.with_context(**{"missing_model": True}) + return IrModelData._module_data_uninstall._original_method( + patched_self, modules_to_remove + ) + + +_module_data_uninstall._original_method = IrModelData._module_data_uninstall +IrModelData._module_data_uninstall = _module_data_uninstall + + +def _module_data_uninstall(self): + """Don't delete many2many relation tables. Only unlink the + ir.model.relation record itself. + """ + self.unlink() + + +IrModelRelation._module_data_uninstall = _module_data_uninstall + + +def _process_ondelete(self): + """Don't break on missing models when deleting their selection fields""" + to_process = self.browse([]) + for selection in self: + try: + self.env[selection.field_id.model] # pylint: disable=pointless-statement + to_process += selection + except KeyError: + continue + return IrModelSelection._process_ondelete._original_method(to_process) + + +_process_ondelete._original_method = IrModelSelection._process_ondelete +IrModelSelection._process_ondelete = _process_ondelete diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py new file mode 100644 index 000000000000..0cec05eab184 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py @@ -0,0 +1,95 @@ +# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging + +from odoo import api +from odoo.exceptions import ValidationError +from odoo.tools import mute_logger + +from odoo.addons.base.models.ir_ui_view import NameManager, View + +_logger = logging.getLogger(__name__) + + +@api.constrains("arch_db") +def _check_xml(self): + """Don't raise or log exceptions in view validation unless explicitely + requested. Mute warnings about views which are common during migration.""" + with mute_logger("odoo.addons.base.models.ir_ui_view"): + try: + return View._check_xml._original_method(self) + except ValidationError as e: + _logger.warning( + "Can't render custom view %s for model %s. " + "Assuming you are migrating between major versions of Odoo. " + "Please review the view contents manually after the migration.\n" + "Error: %s", + self.xml_id, + self.model, + e, + ) + + +def check(self, view): + """Because we captured the exception in _raise_view_error and archived that view, + so info is None, but it is called to info.get('select') in NameManager.check, + which will raise an exception AttributeError, + so we need to override to not raise an exception + """ + try: + return NameManager.check._original_method(self, view) + except AttributeError as e: + if e.args[0] == "'NoneType' object has no attribute 'get'": + pass + else: + raise + + +def _raise_view_error( + self, message, node=None, *, from_exception=None, from_traceback=None +): + """Don't raise or log exceptions in view validation unless explicitely + requested + """ + raise_exception = self.env.context.get("raise_view_error") + to_mute = "odoo.addons.base.models.ir_ui_view" if raise_exception else "not_muted" + with mute_logger(to_mute): + try: + return View._raise_view_error._original_method( + self, + message, + node=node, + from_exception=from_exception, + from_traceback=from_traceback, + ) + except ValueError as e: + _logger.warning( + "Can't render custom view %s for model %s. " + "Assuming you are migrating between major versions of Odoo. " + "Please review the view contents manually after the migration.\n" + "Error: %s", + self.xml_id, + self.model, + e, + ) + + +def _check_field_paths(self, node, field_paths, model_name, use): + """Ignore UnboundLocalError when we squelched the raise about missing fields""" + try: + return View._check_field_paths._original_method( + self, node, field_paths, model_name, use + ) + except UnboundLocalError: # pylint: disable=except-pass + pass + + +_check_xml._original_method = View._check_xml +View._check_xml = _check_xml +check._original_method = NameManager.check +NameManager.check = check +_raise_view_error._original_method = View._raise_view_error +View._raise_view_error = _raise_view_error +_check_field_paths._original_method = View._check_field_paths +View._check_field_paths = _check_field_paths diff --git a/openupgrade_framework/odoo_patch/odoo/api.py b/openupgrade_framework/odoo_patch/odoo/api.py new file mode 100644 index 000000000000..1e4fbac6225f --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/api.py @@ -0,0 +1,43 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging + +from odoo.api import Environment + +_logger = logging.getLogger(__name__) + + +class FakeRecord: + """Artificial construct to handle delete(records) submethod""" + + def __new__(cls): + return object.__new__(cls) + + def __init__(self): + self._name = "ir.model.data" + self.ids = [] + self.browse = lambda x: None + + def __isub__(self, other): + return None + + +def __getitem__(self, model_name): + """This is used to bypass the call self.env[model] + (and other posterior calls) from _module_data_uninstall method of ir.model.data + """ + if ( + hasattr(self, "context") + and isinstance(model_name, str) + and self.context.get("missing_model", False) + ): + if not self.registry.models.get(model_name, False): + new_env = lambda: None # noqa: E731 + new_env._fields = {} + new_env.browse = lambda i: FakeRecord() + return new_env + return Environment.__getitem__._original_method(self, model_name) + + +__getitem__._original_method = Environment.__getitem__ +Environment.__getitem__ = __getitem__ diff --git a/openupgrade_framework/odoo_patch/odoo/models.py b/openupgrade_framework/odoo_patch/odoo/models.py new file mode 100644 index 000000000000..12ec270e2f4c --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/models.py @@ -0,0 +1,42 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging +from uuid import uuid4 + +from odoo.models import BaseModel + +from odoo.addons.base.models.ir_model import MODULE_UNINSTALL_FLAG + +_logger = logging.getLogger(__name__) + + +def unlink(self): + """Don't break on unlink of obsolete records + when called from ir.model::_process_end() + + This only adapts the base unlink method. If overrides of this method + on individual models give problems, add patches for those as well. + """ + if not self.env.context.get(MODULE_UNINSTALL_FLAG): + return BaseModel.unlink._original_method(self) + savepoint = str(uuid4) + try: + self.env.cr.execute( # pylint: disable=sql-injection + 'SAVEPOINT "%s"' % savepoint + ) + return BaseModel.unlink._original_method(self) + except Exception as e: + self.env.cr.execute( # pylint: disable=sql-injection + 'ROLLBACK TO SAVEPOINT "%s"' % savepoint + ) + _logger.warning( + "Could not delete obsolete record with ids %s of model %s: %s", + self.ids, + self._name, + e, + ) + return False + + +unlink._original_method = BaseModel.unlink +BaseModel.unlink = unlink diff --git a/openupgrade_framework/odoo_patch/odoo/modules/__init__.py b/openupgrade_framework/odoo_patch/odoo/modules/__init__.py new file mode 100644 index 000000000000..614d7053c827 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/modules/__init__.py @@ -0,0 +1 @@ +from . import graph, migration diff --git a/openupgrade_framework/odoo_patch/odoo/modules/graph.py b/openupgrade_framework/odoo_patch/odoo/modules/graph.py new file mode 100644 index 000000000000..4bf3f36d9a2c --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/modules/graph.py @@ -0,0 +1,60 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import os + +import odoo +from odoo.modules.graph import Graph + + +def update_from_db(self, cr): + """Prevent reloading of demo data from the new version on major upgrade""" + Graph.update_from_db._original_method(self, cr) + if os.environ.get("OPENUPGRADE_USE_DEMO", "") == "yes": + return + if ( + "base" in self + and self["base"].dbdemo + and self["base"].installed_version < odoo.release.major_version + ): + cr.execute("UPDATE ir_module_module SET demo = false") + for package in self.values(): + package.dbdemo = False + + +def add_modules(self, cr, module_list, force=None): + """Add extra dependencies directly to the graph for immediate installation and + proper dependency resolution. + """ + modules_in = list(module_list) + dependencies = module_list + while dependencies: + cr.execute( + """ + SELECT DISTINCT dep.name + FROM + ir_module_module, + ir_module_module_dependency dep + WHERE + module_id = ir_module_module.id + AND ir_module_module.name in %s + AND dep.name not in %s + """, + (tuple(dependencies), tuple(module_list)), + ) + dependencies = [x[0] for x in cr.fetchall()] + module_list += dependencies + # Set proper state for new dependencies so that any init scripts are run + cr.execute( + """ + UPDATE ir_module_module SET state = 'to install' + WHERE name IN %s AND name NOT IN %s AND state = 'uninstalled' + """, + (tuple(module_list), tuple(modules_in)), + ) + return Graph.add_modules._original_method(self, cr, module_list, force=force) + + +update_from_db._original_method = Graph.update_from_db +Graph.update_from_db = update_from_db +add_modules._original_method = Graph.add_modules +Graph.add_modules = add_modules diff --git a/openupgrade_framework/odoo_patch/odoo/modules/migration.py b/openupgrade_framework/odoo_patch/odoo/modules/migration.py new file mode 100644 index 000000000000..872f84817eb2 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/modules/migration.py @@ -0,0 +1,24 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.modules.migration import MigrationManager + + +def migrate_module(self, pkg, stage): + """In openupgrade, also run migration scripts upon installation. + We want to always pass in pre and post migration files and use a new + argument in the migrate decorator (explained in the docstring) + to decide if we want to do something if a new module is installed + during the migration. + We trick Odoo into running the scripts by temporarily changing the module + state. + """ + to_install = pkg.state == "to install" + if to_install: + pkg.state = "to upgrade" + MigrationManager.migrate_module._original_method(self, pkg, stage) + if to_install: + pkg.state = "to install" + + +migrate_module._original_method = MigrationManager.migrate_module +MigrationManager.migrate_module = migrate_module diff --git a/openupgrade_framework/pyproject.toml b/openupgrade_framework/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/openupgrade_framework/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/openupgrade_framework/readme/CONFIGURE.rst b/openupgrade_framework/readme/CONFIGURE.rst new file mode 100644 index 000000000000..8fad427bf4ac --- /dev/null +++ b/openupgrade_framework/readme/CONFIGURE.rst @@ -0,0 +1,15 @@ +* call your odoo instance with the option ``--load=base,web,openupgrade_framework`` + +or + +* add the key to your configuration file: + +.. code-block:: shell + + [options] + server_wide_modules = web,openupgrade_framework + +When you load the module in either way of these ways, and you have the +`openupgrade_scripts` module in your addons path available, the +`--upgrade-path` option of Odoo will be set automatically to the location +of the OpenUpgrade migration scripts. diff --git a/openupgrade_framework/readme/CONTRIBUTORS.rst b/openupgrade_framework/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..d693b699fbb2 --- /dev/null +++ b/openupgrade_framework/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Stefan Rijnhart +* Sylvain LE GAL diff --git a/openupgrade_framework/readme/CREDITS.rst b/openupgrade_framework/readme/CREDITS.rst new file mode 100644 index 000000000000..c57b7d4144c9 --- /dev/null +++ b/openupgrade_framework/readme/CREDITS.rst @@ -0,0 +1,4 @@ +Many developers have contributed to the OpenUpgrade framework in its previous +incarnation. Their original contributions may no longer needed, or they are +no longer recognizable in their current form but OpenUpgrade would not have +existed at this point without them. diff --git a/openupgrade_framework/readme/DESCRIPTION.rst b/openupgrade_framework/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..96b05a944a01 --- /dev/null +++ b/openupgrade_framework/readme/DESCRIPTION.rst @@ -0,0 +1,27 @@ +This module is a technical module that contains a number of monkeypatches +to improve the behaviour of Odoo when migrating your database using the +OpenUpgrade migration scripts: + +* Prevent dropping columns or tables in the database when fields or models + are obsoleted in the Odoo data model of the target release. After the + migration, you can review and delete unused database tables and columns + using `database_cleanup`. See + https://odoo-community.org/shop/product/database-cleanup-918 +* When data records are deleted during the migration (such as views or other + system records), this is done in a secure mode. If the deletion fails because + of some unforeseen dependency, the deletion will be cancelled and a message + is logged, after which the migration continues. +* Prevent a number of log messages that do not apply when using OpenUpgrade. +* Suppress log messages about failed view validation, which are to be expected + during a migration. +* Run migration scripts for modules that are installed as new dependencies + of upgraded modules (when there are such scripts for those particular + modules) +* Production databases generated with demo data, will be transformed to + non-demo ones. If you want to avoid that, you have to pass through the + environment variable OPENUPGRADE_USE_DEMO, the value "yes". + +For detailed documentation see: + +* https://github.com/OCA/OpenUpgrade/ +* https://oca.github.io/OpenUpgrade diff --git a/openupgrade_framework/readme/DEVELOP.rst b/openupgrade_framework/readme/DEVELOP.rst new file mode 100644 index 000000000000..c65d2cae05d7 --- /dev/null +++ b/openupgrade_framework/readme/DEVELOP.rst @@ -0,0 +1,52 @@ +The `odoo_patch` folder contains python files in a tree that mimicks the +folder tree of the Odoo project. It contains a number of monkey patches +to improve the migration of an Odoo database between two major versions. + +So far, we are able to make everything work without overwriting large blocks +of code, but if larger patches need to be added, please use the method +described below: + +To see the patches added, you can use ``meld`` tools: + +``meld PATH_TO_ODOO_FOLDER/odoo/ PATH_TO_OPENUPGRADE_FRAMEWORK_MODULE/odoo_patch`` + + +To make more easy the diff analysis : + +* Make sure the python files has the same path as the original one. + +* Keep the same indentation as the original file. (using ``if True:`` if required) + +* Add the following two lines at the beginning of your file, to avoid flake8 / pylint + errors + +.. code-block:: python + + # flake8: noqa + # pylint: skip-file + +* When you want to change the code. add the following tags: + +For an addition: + +.. code-block:: python + + # + some code... + # + +For a change: + +.. code-block:: python + + # + some code... + # + +For a removal: + +.. code-block:: python + + # + # Comment the code, instead of removing it. + # diff --git a/openupgrade_framework/readme/INSTALL.rst b/openupgrade_framework/readme/INSTALL.rst new file mode 100644 index 000000000000..020d4947fb63 --- /dev/null +++ b/openupgrade_framework/readme/INSTALL.rst @@ -0,0 +1,2 @@ +This module does not need to be installed on a database. +It simply needs to be available via your ``addons-path``. diff --git a/openupgrade_framework/static/description/banner.png b/openupgrade_framework/static/description/banner.png new file mode 100644 index 000000000000..9dd67ec04cf4 Binary files /dev/null and b/openupgrade_framework/static/description/banner.png differ diff --git a/openupgrade_framework/static/description/icon.png b/openupgrade_framework/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/openupgrade_framework/static/description/icon.png differ diff --git a/openupgrade_framework/static/description/index.html b/openupgrade_framework/static/description/index.html new file mode 100644 index 000000000000..ff8746e6e76e --- /dev/null +++ b/openupgrade_framework/static/description/index.html @@ -0,0 +1,530 @@ + + + + + + +Openupgrade Framework + + + +
+

Openupgrade Framework

+ + +

Beta License: AGPL-3 OCA/OpenUpgrade Translate me on Weblate Try me on Runboat

+

This module is a technical module that contains a number of monkeypatches +to improve the behaviour of Odoo when migrating your database using the +OpenUpgrade migration scripts:

+
    +
  • Prevent dropping columns or tables in the database when fields or models +are obsoleted in the Odoo data model of the target release. After the +migration, you can review and delete unused database tables and columns +using database_cleanup. See +https://odoo-community.org/shop/product/database-cleanup-918
  • +
  • When data records are deleted during the migration (such as views or other +system records), this is done in a secure mode. If the deletion fails because +of some unforeseen dependency, the deletion will be cancelled and a message +is logged, after which the migration continues.
  • +
  • Prevent a number of log messages that do not apply when using OpenUpgrade.
  • +
  • Suppress log messages about failed view validation, which are to be expected +during a migration.
  • +
  • Run migration scripts for modules that are installed as new dependencies +of upgraded modules (when there are such scripts for those particular +modules)
  • +
  • Production databases generated with demo data, will be transformed to +non-demo ones. If you want to avoid that, you have to pass through the +environment variable OPENUPGRADE_USE_DEMO, the value “yes”.
  • +
+

For detailed documentation see:

+ +

Table of contents

+ +
+

Installation

+

This module does not need to be installed on a database. +It simply needs to be available via your addons-path.

+
+
+

Configuration

+
    +
  • call your odoo instance with the option --load=base,web,openupgrade_framework
  • +
+

or

+
    +
  • add the key to your configuration file:
  • +
+
+[options]
+server_wide_modules = web,openupgrade_framework
+
+

When you load the module in either way of these ways, and you have the +openupgrade_scripts module in your addons path available, the +–upgrade-path option of Odoo will be set automatically to the location +of the OpenUpgrade migration scripts.

+
+
+

Development

+

The odoo_patch folder contains python files in a tree that mimicks the +folder tree of the Odoo project. It contains a number of monkey patches +to improve the migration of an Odoo database between two major versions.

+

So far, we are able to make everything work without overwriting large blocks +of code, but if larger patches need to be added, please use the method +described below:

+

To see the patches added, you can use meld tools:

+

meld PATH_TO_ODOO_FOLDER/odoo/ PATH_TO_OPENUPGRADE_FRAMEWORK_MODULE/odoo_patch

+

To make more easy the diff analysis :

+
    +
  • Make sure the python files has the same path as the original one.
  • +
  • Keep the same indentation as the original file. (using if True: if required)
  • +
  • Add the following two lines at the beginning of your file, to avoid flake8 / pylint +errors
  • +
+
+# flake8: noqa
+# pylint: skip-file
+
+
    +
  • When you want to change the code. add the following tags:
  • +
+

For an addition:

+
+# <OpenUpgrade:ADD>
+some code...
+# </OpenUpgrade>
+
+

For a change:

+
+# <OpenUpgrade:CHANGE>
+some code...
+# </OpenUpgrade>
+
+

For a removal:

+
+# <OpenUpgrade:REMOVE>
+# Comment the code, instead of removing it.
+# </OpenUpgrade>
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Therp BV
  • +
  • Opener B.V.
  • +
  • GRAP
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

Many developers have contributed to the OpenUpgrade framework in its previous +incarnation. Their original contributions may no longer needed, or they are +no longer recognizable in their current form but OpenUpgrade would not have +existed at this point without them.

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainers:

+

legalsylvain StefanRijnhart hbrunn

+

This module is part of the OCA/OpenUpgrade project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ +