From 43a2b89b9edcd6c24e778ed53cc3931311503ace Mon Sep 17 00:00:00 2001 From: Flectra Community Bot Date: Sun, 6 Jun 2021 02:13:10 +0000 Subject: [PATCH] Automatic Update form OCA2FC Migrator --- account_tax_balance/COPYRIGHT | 1 + .../migrations/14.0.1.0.0/pre-migration.py | 34 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/account_tax_balance/COPYRIGHT b/account_tax_balance/COPYRIGHT index 28f0e7d..f792d48 100644 --- a/account_tax_balance/COPYRIGHT +++ b/account_tax_balance/COPYRIGHT @@ -12,6 +12,7 @@ Most of the files are Copyright 2020 Opener B.V. Copyright 2020 Ozono Multimedia S.L.L. Copyright 2020 Tecnativa - Pedro M. Baeza + Copyright 2021 Simone Rubino - Agile Business Group Copyright 2018 Flectra Community Many files also contain contributions from third diff --git a/account_tax_balance/migrations/14.0.1.0.0/pre-migration.py b/account_tax_balance/migrations/14.0.1.0.0/pre-migration.py index 3d7a40e..ec74d7f 100644 --- a/account_tax_balance/migrations/14.0.1.0.0/pre-migration.py +++ b/account_tax_balance/migrations/14.0.1.0.0/pre-migration.py @@ -1,17 +1,31 @@ # Copyright 2020 Ozono Multimedia S.L.L. +# Copyright 2021 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openupgradelib import openupgrade -field_renames = [ - ( - "account.move", - "account_move", - "move_type", - "financial_type", - ), -] - @openupgrade.migrate() def migrate(env, version): - openupgrade.rename_fields(env, field_renames) + """ + Column `move_type` of table `account_move` has been renamed to `financial_type` + because `move_type` is now used by the core, + so the column is moved during migration of module `account` in the core. + Enterprise renames it to `move_type_custom`; + OpenUpgrade renames it to its legacy name. + Move data from the renamed column to the new `financial_type` column. + """ + old_move_type_column = "move_type" + new_move_type_column = "financial_type" + move_table_name = "account_move" + enterprise_move_type_rename = "move_type_custom" + ou_move_type_rename = openupgrade.get_legacy_name(old_move_type_column) + + for move_type_rename in (enterprise_move_type_rename, ou_move_type_rename): + if openupgrade.column_exists(env.cr, move_table_name, move_type_rename): + openupgrade.rename_columns( + env.cr, + { + move_table_name: [(move_type_rename, new_move_type_column)], + }, + ) + break