Skip to content
Merged
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 @@ -95,6 +95,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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should adapt the docstring of this method...

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not testing really the feature, as this module is not installed during the upgrade.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pedrobaeza

Look at .github/workflows/test.yml, this file is copied to spreadsheet directory which is installed during the upgrade.

Do you think I should create a directory containing only tests ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see, it seems it works for this version, but for the next ones, spreadsheet will be already installed.

# 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