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)