Skip to content

Commit

Permalink
[FIX] project:post-migration: fill stage_id in projects is not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed Jan 15, 2024
1 parent 9064d39 commit b89bc0f
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions openupgrade_scripts/scripts/project/15.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,6 @@ def _fill_project_task_display_project_id(env):
""",
)

def _fill_project_project_stage(env):
# use data from analytic_account_stage
env.cr.execute("""
alter table account_analytic_account drop constraint if exists account_analytic_account_stage_id_fkey;
""")
env.cr.execute("""
UPDATE project_project_stage SET active = false;
INSERT INTO project_project_stage
(create_date, write_date, sequence, name, fold, create_uid, write_uid, active)
SELECT create_date, write_date, sequence, name, fold, create_uid, write_uid, true
FROM analytic_account_stage;
""")
env.cr.execute("""
WITH BQ AS(
SELECT pps.id as pps_id, aas.id as aas_id from project_project_stage pps
INNER JOIN analytic_account_stage aas on aas.name = pps.name
WHERE pps.name = aas.name
)
UPDATE account_analytic_account aaa
SET stage_id = (
SELECT BQ.pps_id
FROM account_analytic_account aaa2
JOIN BQ ON BQ.aas_id = aaa2.stage_id
AND aaa.id = aaa2.id);
""")


@openupgrade.migrate()
def migrate(env, version):
Expand All @@ -111,5 +85,4 @@ def migrate(env, version):
"mail_template_data_project_task",
"rating_project_request_email_template",
],
)
_fill_project_project_stage(env)
)

0 comments on commit b89bc0f

Please sign in to comment.