Skip to content

Commit

Permalink
[IMP] openupgrade_framework: avoid analytic migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Feb 28, 2025
1 parent 79040ba commit e3188ee
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion openupgrade_framework/odoo_patch/odoo/modules/migration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright Odoo Community Association (OCA)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
import os

from odoo.modules.migration import MigrationManager


Expand All @@ -12,6 +14,24 @@ def migrate_module(self, pkg, stage):
We trick Odoo into running the scripts by temporarily changing the module
state.
"""

def _get_migration_files(pkg, version, stage):
"""return a list of migration script files"""
scripts_to_avoid = [
("analytic", "1.2", "pre"), # https://github.com/odoo/odoo/pull/199604
]
m = self.migrations[pkg.name]
return sorted(
(
f
for k in m
for f in m[k].get(version, [])
if os.path.basename(f).startswith(f"{stage}-")
and (pkg.name, version, stage) not in scripts_to_avoid
),
key=os.path.basename,
)

to_install = pkg.state == "to install"
if to_install:
pkg.state = "to upgrade"
Expand All @@ -20,5 +40,11 @@ def migrate_module(self, pkg, stage):
pkg.state = "to install"


migrate_module._get_migration_files._original_method = (
MigrationManager.migrate_module._get_migration_files
)
MigrationManager.migrate_module._get_migration_files = (
migrate_module._get_migration_files
)
migrate_module._original_method = MigrationManager.migrate_module
MigrationManager.migrate_module = migrate_module

0 comments on commit e3188ee

Please sign in to comment.