diff --git a/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt b/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt index dab7a73ecc71..2cab0a60e09b 100644 --- a/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt +++ b/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt @@ -331,8 +331,9 @@ account / account.move / matched_percentage (float) : DEL account / account.move / reverse_entry_id (many2one) : DEL relation: account.move account / account.move / reversed_entry_id (many2one) : NEW relation: account.move account / account.invoice / refund_invoice_id (many2one) : DEL relation: account.invoice -# DONE: pre-migration: renamed fields -# DONE: post-migration: used refund_invoice_id to fill reversed_entry_id in case is empty +# DONE: pre-migration: lift FK constraint in reverse_entry_id +# DONE: post-migration: used refund_invoice_id to fill reverse_entry_id in case is empty (for invoices transformed to moves) +# DONE: post-migration: used reverse_entry_id to fill reversed_entry_id in case is empty account / account.move / tax_type_domain (char) : DEL # NOTHING TO DO: renamed to invoice_filter_type_domain, but still is non stored diff --git a/addons/account/migrations/13.0.1.1/post-migration.py b/addons/account/migrations/13.0.1.1/post-migration.py index 3f2f2e4abb80..33eb4c2eee35 100644 --- a/addons/account/migrations/13.0.1.1/post-migration.py +++ b/addons/account/migrations/13.0.1.1/post-migration.py @@ -581,14 +581,24 @@ def migration_voucher_moves(env): def fill_account_move_reversed_entry_id(env): + # copy refund_invoice_id to reverse_entry_id openupgrade.logged_query( env.cr, """ UPDATE account_move am - SET reversed_entry_id = am2.id + SET reverse_entry_id = am2.id FROM account_invoice ai JOIN account_invoice ai2 ON ai.refund_invoice_id = ai2.id JOIN account_move am2 ON am2.old_invoice_id = ai2.id - WHERE am.reversed_entry_id IS NULL AND am.old_invoice_id = ai.id""" + WHERE am.reverse_entry_id IS NULL AND am.old_invoice_id = ai.id""" + ) + # copy reverse_entry_id to reversed_entry_id (the relation is reversed in 13.0) + openupgrade.logged_query( + env.cr, """ + UPDATE account_move am + SET reversed_entry_id = am2.id + FROM account_move am2 + WHERE am.reversed_entry_id IS NULL AND am2.reverse_entry_id = am.id + """ ) diff --git a/addons/account/migrations/13.0.1.1/pre-migration.py b/addons/account/migrations/13.0.1.1/pre-migration.py index e57abf7cdd66..33ac7e9afa59 100644 --- a/addons/account/migrations/13.0.1.1/pre-migration.py +++ b/addons/account/migrations/13.0.1.1/pre-migration.py @@ -34,7 +34,6 @@ _field_renames = [ ('account.move', 'account_move', 'amount', 'amount_total'), - ('account.move', 'account_move', 'reverse_entry_id', 'reversed_entry_id'), ] _field_sale_renames = [ @@ -340,6 +339,7 @@ def migrate(env, version): fill_account_move_line(env) create_res_partner_ranks(env) delete_fk_constraints(env) + openupgrade.lift_constraints(env.cr, "account_move", "reverse_entry_id") fill_account_move_commercial_partner_id(env) set_account_move_currency_id_required(env) add_helper_invoice_move_rel(env)