[OU-FIX] account_statement_import_online: Conditional renaming + filling

As the changes for having online raw data have been made only on v12
and v14, people coming from v13 won't have this column populated on
the DB, so we need to be tolerant with that circumstance.
This commit is contained in:
Pedro M. Baeza
2022-10-22 11:30:43 +02:00
parent 6fdf17dc8b
commit c8148fab79
2 changed files with 12 additions and 9 deletions

View File

@@ -7,9 +7,11 @@ from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"UPDATE account_bank_statement_line SET raw_data={online_raw_data}".format(
online_raw_data=openupgrade.get_legacy_name("online_raw_data")
),
)
column = openupgrade.get_legacy_name("online_raw_data")
if openupgrade.column_exists(env.cr, "account_bank_statement_line", column):
openupgrade.logged_query(
env.cr,
"UPDATE account_bank_statement_line SET raw_data={online_raw_data}".format(
online_raw_data=column,
),
)

View File

@@ -13,6 +13,7 @@ _column_renames = {
@openupgrade.migrate()
def migrate(env, version):
if not version:
return
openupgrade.rename_columns(env.cr, _column_renames)
if openupgrade.column_exists(
env.cr, "account_bank_statement_line", "online_raw_data"
):
openupgrade.rename_columns(env.cr, _column_renames)