diff --git a/openupgrade_framework/README.rst b/openupgrade_framework/README.rst new file mode 100644 index 000000000000..7838c26a0c9f --- /dev/null +++ b/openupgrade_framework/README.rst @@ -0,0 +1,210 @@ +===================== +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:: 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:: python + + # flake8: noqa + # pylint: skip-file + +- When you want to change the code. add the following tags: + +For an addition: + +.. code:: python + + # + some code... + # + +For a change: + +.. code:: python + + # + some code... + # + +For a removal: + +.. code:: 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 +* Hunki Enterprises BV + +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 +.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px + :target: https://github.com/hbrunn + :alt: hbrunn + +Current `maintainers `__: + +|maintainer-legalsylvain| |maintainer-StefanRijnhart| |maintainer-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. 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..3f6dc6d15d7a --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/__init__.py @@ -0,0 +1 @@ +from . import addons, api, models, modules, tests 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..cdd8d85e0a99 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py @@ -0,0 +1,103 @@ +# 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.tools import mute_logger + +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 + + +@api.model +def _process_end(self, modules): + """Don't warn about upgrade conventions from Odoo + ('fields should be explicitly removed by an upgrade script') + """ + with mute_logger("odoo.addons.base.models.ir_model"): + return IrModelData._process_end._original_method(self, modules) + + +_process_end._original_method = IrModelData._process_end +IrModelData._process_end = _process_end + + +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..88fa084e1976 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py @@ -0,0 +1,81 @@ +# 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.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): + """Mute warnings about views which are common during migration""" + with mute_logger("odoo.addons.base.models.ir_ui_view"): + return View._check_xml._original_method(self) + + +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/odoo_patch/odoo/tests/__init__.py b/openupgrade_framework/odoo_patch/odoo/tests/__init__.py new file mode 100644 index 000000000000..848c37a25e63 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/tests/__init__.py @@ -0,0 +1 @@ +from . import loader diff --git a/openupgrade_framework/odoo_patch/odoo/tests/loader.py b/openupgrade_framework/odoo_patch/odoo/tests/loader.py new file mode 100644 index 000000000000..e7cf0a84fdeb --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/tests/loader.py @@ -0,0 +1,59 @@ +# Copyright 2023 Hunki Enterprises BV (https://hunki-enterprises.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import importlib +import inspect +import os.path +import sys + +from odoo.tests import loader +from odoo.tools import config + + +def _get_tests_modules(mod): + """ + Make odoo load tests from openupgrade_scripts/scripts/$module/$version/tests + instead of the standard location + """ + # + package = None + frame = inspect.currentframe().f_back + while frame and not package: + package = frame.f_locals.get("package") + frame = frame.f_back + + if not package: + return [] + + spec = importlib.util.spec_from_file_location( + "%s_migration_tests" % mod.name, + os.path.join( + config["upgrade_path"], + package.name, + package.data["version"] or ".", + "tests", + "__init__.py", + ), + ) + + if not spec: + return [] + + test_module = importlib.util.module_from_spec(spec) + sys.modules[test_module.__name__] = test_module + + try: + spec.loader.exec_module(test_module) + except FileNotFoundError: + del sys.modules[test_module.__name__] + return [] + # + tests_mod = importlib.import_module(spec.name) + return [ + mod_obj + for name, mod_obj in inspect.getmembers(tests_mod, inspect.ismodule) + if name.startswith("test_") + ] + + +_get_tests_modules._original_method = loader._get_tests_modules +loader._get_tests_modules = _get_tests_modules 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.md b/openupgrade_framework/readme/CONFIGURE.md new file mode 100644 index 000000000000..13ef1e5b0946 --- /dev/null +++ b/openupgrade_framework/readme/CONFIGURE.md @@ -0,0 +1,16 @@ +- call your odoo instance with the option + `--load=base,web,openupgrade_framework` + +or + +- add the key to your configuration file: + +``` 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.md b/openupgrade_framework/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..a108409b034c --- /dev/null +++ b/openupgrade_framework/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Stefan Rijnhart \<\> +- Sylvain LE GAL \<\> diff --git a/openupgrade_framework/readme/CREDITS.md b/openupgrade_framework/readme/CREDITS.md new file mode 100644 index 000000000000..fa515612942e --- /dev/null +++ b/openupgrade_framework/readme/CREDITS.md @@ -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.md b/openupgrade_framework/readme/DESCRIPTION.md new file mode 100644 index 000000000000..71cb68ac0b99 --- /dev/null +++ b/openupgrade_framework/readme/DESCRIPTION.md @@ -0,0 +1,29 @@ +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 + +- 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: + +- +- diff --git a/openupgrade_framework/readme/DEVELOP.md b/openupgrade_framework/readme/DEVELOP.md new file mode 100644 index 000000000000..9d4c548862be --- /dev/null +++ b/openupgrade_framework/readme/DEVELOP.md @@ -0,0 +1,50 @@ +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 + +``` python +# flake8: noqa +# pylint: skip-file +``` + +- When you want to change the code. add the following tags: + +For an addition: + +``` python +# +some code... +# +``` + +For a change: + +``` python +# +some code... +# +``` + +For a removal: + +``` python +# +# Comment the code, instead of removing it. +# +``` diff --git a/openupgrade_framework/readme/INSTALL.md b/openupgrade_framework/readme/INSTALL.md new file mode 100644 index 000000000000..471a1d162ce1 --- /dev/null +++ b/openupgrade_framework/readme/INSTALL.md @@ -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..4cc8d953e1b4 --- /dev/null +++ b/openupgrade_framework/static/description/index.html @@ -0,0 +1,535 @@ + + + + + + +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
  • +
  • Hunki Enterprises BV
  • +
+
+
+

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.

+
+
+
+ + diff --git a/pandoc-3.1.12.1-1-amd64.deb b/pandoc-3.1.12.1-1-amd64.deb new file mode 100644 index 000000000000..d8e51d6c379a Binary files /dev/null and b/pandoc-3.1.12.1-1-amd64.deb differ