2021-03-12 16:20:48 +00:00
|
|
|
# Copyright 2020 Ozono Multimedia S.L.L.
|
2021-06-06 02:13:10 +00:00
|
|
|
# Copyright 2021 Simone Rubino - Agile Business Group
|
2021-03-12 16:20:48 +00:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
from openupgradelib import openupgrade
|
|
|
|
|
|
|
|
|
|
|
|
@openupgrade.migrate()
|
|
|
|
def migrate(env, version):
|
2021-06-06 02:13:10 +00:00
|
|
|
"""
|
|
|
|
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"
|
2021-10-10 02:10:21 +00:00
|
|
|
move_model_name = "account.move"
|
2021-06-06 02:13:10 +00:00
|
|
|
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):
|
2021-10-10 02:10:21 +00:00
|
|
|
openupgrade.rename_fields(
|
|
|
|
env,
|
|
|
|
[
|
|
|
|
(
|
|
|
|
move_model_name,
|
|
|
|
move_table_name,
|
|
|
|
move_type_rename,
|
|
|
|
new_move_type_column,
|
|
|
|
),
|
|
|
|
],
|
2021-06-06 02:13:10 +00:00
|
|
|
)
|
|
|
|
break
|