From 198977d40ea7f00f50ccc8dfb48026012654a595 Mon Sep 17 00:00:00 2001
From: Alvaro Fuentes <afu@odoo.com>
Date: Wed, 19 Apr 2023 06:55:33 +0000
Subject: [PATCH] [FIX] core: fix majorless upgrade

When we compare majorless scripts we must ignore the Odoo version.
Otherwise a module upgrade without major Odoo upgrade would fail to run
local scripts majorless scripts. That's what happens for example when
users click the upgrade button of a module.

Example: upgrade from `11.0.1.0` to `11.0.2.0`, with a local `2.0` folder
for upgrades.
```
11.0.1.0 < 11.0.2.0 < 11.0.2.0 -> False (check before this patch)
     1.0 <      2.0 <=     2.0 -> True  (check with this patch)
```
While still: upgrade from `11.0.2.0` to `12.0.2.0`
```
11.0.2.0 < 12.0.2.0 < 12.0.2.0 -> False (before this patch)
     2.0 <      2.0 <=     2.0 -> False (with this patch)
```

closes odoo/odoo#119147

X-original-commit: 84ab74c62a19d08de8b6c7c4e3f3300d7e79bcf9
Signed-off-by: Christophe Simonis <chs@odoo.com>
---
 odoo/modules/migration.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/odoo/modules/migration.py b/odoo/modules/migration.py
index 141a11134a4d..65f5459f32e6 100644
--- a/odoo/modules/migration.py
+++ b/odoo/modules/migration.py
@@ -155,7 +155,8 @@ class MigrationManager(object):
             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
+                # In which case we must compare just the module version
+                return parsed_installed_version[2:] < parse_version(full_version)[2:] <= current_version[2:]
 
             return parsed_installed_version < parse_version(full_version) <= current_version
 
-- 
GitLab