From e2361c6a90f07f712c69a795ab3f33c3d84842d3 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 26 May 2026 11:54:44 +0200 Subject: [PATCH] [FIX] project: don't crash on types with exclusively inactive projects --- .../scripts/project/19.0.1.3/post-migration.py | 9 ++++++++- .../project/tests/data_project_migration.py | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/project/tests/data_project_migration.py diff --git a/openupgrade_scripts/scripts/project/19.0.1.3/post-migration.py b/openupgrade_scripts/scripts/project/19.0.1.3/post-migration.py index a93ea722b4c1..64df8d9fe45e 100644 --- a/openupgrade_scripts/scripts/project/19.0.1.3/post-migration.py +++ b/openupgrade_scripts/scripts/project/19.0.1.3/post-migration.py @@ -39,7 +39,14 @@ def project_task_type_rating(env): ORDER BY write_date DESC LIMIT 1 """, - (tuple(task_type.project_ids.ids),), + ( + tuple( + ( + task_type.project_ids + or task_type.with_context(active_test=False).project_ids + ).ids + ), + ), ) for vals in env.cr.dictfetchall(): task_type.write(vals) diff --git a/openupgrade_scripts/scripts/project/tests/data_project_migration.py b/openupgrade_scripts/scripts/project/tests/data_project_migration.py new file mode 100644 index 000000000000..43d0e58d1700 --- /dev/null +++ b/openupgrade_scripts/scripts/project/tests/data_project_migration.py @@ -0,0 +1,18 @@ +env = locals().get("env") + +# create task type with exclusively inactive projects +task_type = env["project.task.type"].create( + { + "name": "Task type", + } +) +project = env["project.project"].create( + { + "name": "Inactive project", + "active": False, + "type_ids": [(6, 0, task_type.ids)], + } +) + + +env.cr.commit()