[FIX] core: correctly handle major-less upgrade scripts during major version change

closes odoo/odoo#117948

X-original-commit: c38b5baaeac28a7952601878a5b5efadf7f52984
Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
Christophe Simonis
2023-04-06 17:21:00 +02:00
parent dd9973d4df
commit 924487a72d
+15 -4
View File
@@ -148,12 +148,23 @@ class MigrationManager(object):
parsed_installed_version = parse_version(installed_version)
current_version = parse_version(convert_version(pkg.data['version']))
def compare(version):
if version == "0.0.0" and parsed_installed_version < current_version:
return True
full_version = convert_version(version)
majorless_version = (version != full_version)
if majorless_version:
# We should not re-execute major-less scripts when upgrading to new Odoo version
# a module in `9.0.2.0` should not re-execute a `2.0` script when upgrading to `10.0.2.0`.
return parsed_installed_version < parse_version(full_version) < current_version
return parsed_installed_version < parse_version(full_version) <= current_version
versions = _get_migration_versions(pkg, stage)
for version in versions:
if ((version == "0.0.0" and parsed_installed_version < current_version)
or parsed_installed_version < parse_version(convert_version(version)) <= current_version):
if compare(version):
strfmt = {'addon': pkg.name,
'stage': stage,
'version': stageformat[stage] % version,