Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] openupgrade_framework : end-migration scripts are forced … #4107

Draft
wants to merge 3 commits into
base: 16.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ jobs:
for snippet in openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py; do
odoo-old/odoo-bin shell -d $DB < $snippet
done
- name: Test end-migration script for newly installed module (i.e. "spreadsheet" for v16)
run: |
END_SCRIPT_TEST=openupgrade/openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py
NEW_MODULE_SCRIPT_DIR=openupgrade/openupgrade_scripts/scripts/spreadsheet/16.0.1.0/
mkdir -p $NEW_MODULE_SCRIPT_DIR
cp $END_SCRIPT_TEST $NEW_MODULE_SCRIPT_DIR
- name: OpenUpgrade test
run: |
# select modules and perform the upgrade
Expand Down
5 changes: 5 additions & 0 deletions openupgrade_framework/odoo_patch/odoo/modules/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ def migrate_module(self, pkg, stage):
to_install = pkg.state == "to install"
if to_install:
pkg.state = "to upgrade"
load_state_to_install = getattr(pkg, "load_state", False)
if load_state_to_install == "to install":
pkg.load_state = "to upgrade"
MigrationManager.migrate_module._original_method(self, pkg, stage)
if to_install:
pkg.state = "to install"
if load_state_to_install == "to install":
pkg.load_state = "to install"


migrate_module._original_method = MigrationManager.migrate_module
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import test_base_migration
from . import test_newly_installed_end_migration
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Odoo Community Association (OCA)
# Copyright 2023 Guillaume Masson <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


@openupgrade.migrate(no_version=True)
def migrate(env, version):
params = env["ir.config_parameter"].sudo()
params.set_param("openupgrade.test_end_migration", "Executed")
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo.tests import TransactionCase, tagged


@tagged('-at_install', 'post_install')
class TestNewlyInstalledEndMigration(TransactionCase):
def test_newly_installed_end_migration(self):
"""Make sure the code of the end-migration script has been executed"""
params = self.env["ir.config_parameter"].sudo()
res = params.get_param("openupgrade.test_end_migration", default="Not executed")
self.assertEqual(res, "Executed")
Loading