Skip to content

Commit bdab4ce

Browse files
committed
[FIX] util/domains: ast.Constant doesn't exist in Python2
Example error: ``` 2025-04-18 16:00:25,979 531760 ERROR test_9_10 odoo.modules.migration: module base: Each pre-migration file must have a "migrate(cr, installed_version)" function ``` The problem is that the AttributeError in Odoo 10 hides the real issue: ``` 'module' object has no attribute 'Constant' ``` See: https://github.com/odoo/odoo/blob/28c3f51c4878fbcd79b2e819948465fcf2160ebc/odoo/modules/migration.py#L166-L167 closes #264 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 45cd566 commit bdab4ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/util/domains.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ def is_leaf(leaf):
102102
del expression # unset so it's not used directly
103103

104104

105-
AST_CONSTANT_TYPES = (ast.Constant, ast.Str) if sys.version_info < (3, 12) else (ast.Constant,)
105+
AST_CONSTANT_TYPES = (
106+
(ast.Str,)
107+
if sys.version_info < (3, 0)
108+
else (ast.Constant, ast.Str)
109+
if sys.version_info < (3, 12)
110+
else (ast.Constant,)
111+
)
106112

107113
_logger = logging.getLogger(__name__)
108114
DomainField = collections.namedtuple("DomainField", "table domain_column model_select")

0 commit comments

Comments
 (0)