From 5536859432708d5c681a6d3084affc71e5245b5d Mon Sep 17 00:00:00 2001 From: odooNextev Date: Thu, 14 Dec 2023 11:38:27 +0100 Subject: [PATCH] [FIX] l10n_it_delivery_note: fix join clause in pre-migrate script --- .../migrations/13.0.1.0.0/pre-migrate.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/l10n_it_delivery_note/migrations/13.0.1.0.0/pre-migrate.py b/l10n_it_delivery_note/migrations/13.0.1.0.0/pre-migrate.py index 8c3849fdabf2..d8e176d63cc5 100644 --- a/l10n_it_delivery_note/migrations/13.0.1.0.0/pre-migrate.py +++ b/l10n_it_delivery_note/migrations/13.0.1.0.0/pre-migrate.py @@ -24,16 +24,21 @@ def migrate(env, version): ), ) # update invoice_id ref in table + if openupgrade.column_exists(env.cr, "account_move", "old_invoice_id"): + clause = "am.old_invoice_id = inv.id" + else: + clause = "am.id = inv.move_id" query = """ UPDATE {table} SET invoice_id = am.id FROM account_invoice inv - JOIN account_move am ON am.id = inv.move_id + JOIN account_move am ON {clause} WHERE invoice_id = inv.id """.format( - table=table + table=table, + clause=clause, ) openupgrade.logged_query( env.cr,