[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.
This commit is contained in:
Pedro M. Baeza
2024-05-24 09:13:35 +02:00
parent cc2164e7de
commit b4a5b8de63
2 changed files with 9 additions and 3 deletions

View File

@@ -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"

View File

@@ -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"])