From 96f89550ce87228ddd47a0dfc0477178e7e7914d Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Tue, 17 Dec 2024 15:43:58 +0100 Subject: [PATCH] [OU] helpdesk_mgmt_project: Migration script was not working when migrating from a previous major version --- .../migrations/16.0.2.2.0/post-migration.py | 4 ++++ helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/helpdesk_mgmt_project/migrations/16.0.2.2.0/post-migration.py b/helpdesk_mgmt_project/migrations/16.0.2.2.0/post-migration.py index 55dc1c2012..b48b233d51 100644 --- a/helpdesk_mgmt_project/migrations/16.0.2.2.0/post-migration.py +++ b/helpdesk_mgmt_project/migrations/16.0.2.2.0/post-migration.py @@ -3,10 +3,14 @@ from openupgradelib import openupgrade +from odoo.tools.sql import column_exists + @openupgrade.migrate() def migrate(env, version): """Set the default_project_id value in the project company.""" + if not column_exists(env.cr, "helpdesk_ticket_team", "old_default_project_id"): + return env.cr.execute( """ SELECT htt.id, htt.old_default_project_id, pp.company_id diff --git a/helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py b/helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py index 37524ef7d7..9759f5d4c7 100644 --- a/helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py +++ b/helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py @@ -3,6 +3,8 @@ from openupgradelib import openupgrade +from odoo.tools.sql import column_exists + column_renames = { "helpdesk_ticket_team": [("default_project_id", "old_default_project_id")], } @@ -11,4 +13,5 @@ @openupgrade.migrate() def migrate(env, version): """Rename the column to keep the old value.""" - openupgrade.rename_columns(env.cr, column_renames) + if column_exists(env.cr, "helpdesk_ticket_team", "default_project_id"): + openupgrade.rename_columns(env.cr, column_renames)