From b4a5b8de6337e91ffec9696d48ca13f02dce1cba Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 24 May 2024 09:13:35 +0200 Subject: [PATCH] [OU-FIX] account_payment_order: Don't execute on DB cleaned up If v14 database has been cleaned up before migrating to v15, these scripts will fail, as the checks are not taking into account this possibility. This commit adds such possibility. --- .../migrations/15.0.2.0.0/post-migration.py | 10 +++++++--- .../migrations/15.0.2.0.0/pre-migration.py | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/account_payment_order/migrations/15.0.2.0.0/post-migration.py b/account_payment_order/migrations/15.0.2.0.0/post-migration.py index 173de3d86..b9ae90b0a 100644 --- a/account_payment_order/migrations/15.0.2.0.0/post-migration.py +++ b/account_payment_order/migrations/15.0.2.0.0/post-migration.py @@ -162,9 +162,13 @@ def _insert_payment_line_payment_link(env): @openupgrade.migrate() def migrate(env, version): - if openupgrade.column_exists(env.cr, "account_payment", "old_bank_payment_line_id"): - # No execution if the column exists, as that means that this DB comes from v14 - # with the refactoring already applied + if not openupgrade.table_exists( + env.cr, "bank_payment_line" + ) or openupgrade.column_exists( + env.cr, "account_payment", "old_bank_payment_line_id" + ): + # No execution, as that means that this DB comes from v14 with the refactoring + # already applied and possibly database cleaned up return openupgrade.logged_query( env.cr, "ALTER TABLE account_payment ALTER move_id DROP NOT NULL" diff --git a/account_payment_order/migrations/15.0.2.0.0/pre-migration.py b/account_payment_order/migrations/15.0.2.0.0/pre-migration.py index ec25c07e9..d4907fccf 100644 --- a/account_payment_order/migrations/15.0.2.0.0/pre-migration.py +++ b/account_payment_order/migrations/15.0.2.0.0/pre-migration.py @@ -5,4 +5,6 @@ from openupgradelib import openupgrade @openupgrade.migrate() def migrate(env, version): + if not openupgrade.table_exists(env.cr, "bank_payment_line"): + return # if coming from 14.2.0.0 openupgrade.remove_tables_fks(env.cr, ["bank_payment_line"])