Skip to content

Commit

Permalink
Merge pull request #669 from dixmit/16.0-ou
Browse files Browse the repository at this point in the history
[16.0][OU-FIX] helpdesk_mgmt_project: Migration script was not working when migrating from a previous major version
  • Loading branch information
pedrobaeza authored Dec 18, 2024
2 parents f371905 + 96f8955 commit ca97414
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions helpdesk_mgmt_project/migrations/16.0.2.2.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
}
Expand All @@ -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)

0 comments on commit ca97414

Please sign in to comment.