diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb98fca398da..01e721f2268c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,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/openupgrade_framework/odoo_patch/odoo/__init__.py b/openupgrade_framework/odoo_patch/odoo/__init__.py index 3f6dc6d15d7a..64a54f17e628 100644 --- a/openupgrade_framework/odoo_patch/odoo/__init__.py +++ b/openupgrade_framework/odoo_patch/odoo/__init__.py @@ -1 +1 @@ -from . import addons, api, models, modules, tests +from . import addons, api, models, modules 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 index cdd8d85e0a99..1185d8c0b027 100644 --- a/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py @@ -3,7 +3,6 @@ from openupgradelib import openupgrade from odoo import api, models -from odoo.tools import mute_logger from odoo.addons.base.models.ir_model import ( IrModel, @@ -64,19 +63,6 @@ def _module_data_uninstall(self, modules_to_remove): 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. diff --git a/openupgrade_framework/odoo_patch/odoo/tests/__init__.py b/openupgrade_framework/odoo_patch/odoo/tests/__init__.py deleted file mode 100644 index 848c37a25e63..000000000000 --- a/openupgrade_framework/odoo_patch/odoo/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import loader diff --git a/openupgrade_framework/odoo_patch/odoo/tests/loader.py b/openupgrade_framework/odoo_patch/odoo/tests/loader.py deleted file mode 100644 index e7cf0a84fdeb..000000000000 --- a/openupgrade_framework/odoo_patch/odoo/tests/loader.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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