From 6b7f4f578b298ff3c7150385fc11fa9d1be91c30 Mon Sep 17 00:00:00 2001 From: Don Kendall Date: Mon, 25 May 2026 21:14:08 -0400 Subject: [PATCH] [OU-ADD] l10n_tr_nilvera: convert environment selection to use_test_env boolean rename_columns preserves the 18.0 res.company.l10n_tr_nilvera_environment selection ('production'/'sandbox') as openupgrade_legacy_19_0_*. add_fields creates the new boolean l10n_tr_nilvera_use_test_env. map_values maps 'sandbox' -> True, 'production' -> False; NULL rows keep the manifest default (False). --- docsource/modules180-190.rst | 2 +- .../l10n_tr_nilvera/19.0.1.0/pre-migration.py | 51 +++++++++++++++++++ .../19.0.1.0/upgrade_analysis_work.txt | 28 ++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/pre-migration.py create mode 100644 openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules180-190.rst b/docsource/modules180-190.rst index e7f797ce0766..e6207d044d0f 100644 --- a/docsource/modules180-190.rst +++ b/docsource/modules180-190.rst @@ -654,7 +654,7 @@ Module coverage 18.0 -> 19.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | l10n_tr | |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| l10n_tr_nilvera | | | +| l10n_tr_nilvera |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | l10n_tr_nilvera_edispatch | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/pre-migration.py new file mode 100644 index 000000000000..c9e552c019ec --- /dev/null +++ b/openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/pre-migration.py @@ -0,0 +1,51 @@ +from openupgradelib import openupgrade + +# Semantic conversion: the 18.0 res.company.l10n_tr_nilvera_environment +# selection (values 'production' / 'sandbox') is replaced in 19.0 by a +# new boolean res.company.l10n_tr_nilvera_use_test_env. The 18.0 value +# carries meaning ('sandbox' = test environment); preserve and map it +# before Odoo's update_db drops the legacy column. +# +# Steps: +# 1. Rename the legacy selection column out of the way (-> openupgrade_legacy_19_0_*) +# so update_db doesn't reject the type-incompatible NEW column on the same name. +# 2. Add the new boolean column via add_fields (creates the column + +# ir_model_fields entry + xmlid). Default False so non-NULL rows in +# 18.0 with NULL get the manifest default. +# 3. Map values: 'sandbox' -> True (test env), 'production' -> False (live env). +# Rows where the legacy column is NULL are left at the column's default (False). +# +# Precedent: hr_holidays/19.0.1.6/pre-migration.py (yes/no -> boolean pattern). + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_columns( + env.cr, + { + "res_company": [ + ("l10n_tr_nilvera_environment", None), + ], + }, + ) + openupgrade.add_fields( + env, + [ + ( + "l10n_tr_nilvera_use_test_env", + "res.company", + "res_company", + "boolean", + None, + "l10n_tr_nilvera", + False, + ), + ], + ) + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("l10n_tr_nilvera_environment"), + "l10n_tr_nilvera_use_test_env", + [("sandbox", True), ("production", False)], + table="res_company", + ) diff --git a/openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..d029fcb9d4af --- /dev/null +++ b/openupgrade_scripts/scripts/l10n_tr_nilvera/19.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,28 @@ +---Models in module 'l10n_tr_nilvera'--- +---Fields in module 'l10n_tr_nilvera'--- +l10n_tr_nilvera / res.company / l10n_tr_nilvera_environment (selection): DEL required, selection_keys: ['production', 'sandbox'] +l10n_tr_nilvera / res.company / l10n_tr_nilvera_use_test_env (boolean): NEW required, hasdefault: default + +# DONE: semantic conversion handled in pre-migration. The 18.0 selection +# `l10n_tr_nilvera_environment` is preserved as the legacy column +# `openupgrade_legacy_19_0_l10n_tr_nilvera_environment`; the new boolean +# `l10n_tr_nilvera_use_test_env` is added by add_fields and populated by +# map_values: 'sandbox' → True, 'production' → False. Existing rows +# where the legacy column is NULL get the field's manifest default. + +l10n_tr_nilvera / res.partner / invoice_edi_format (False) : selection_keys added: [pint_anz, pint_sg] (most likely nothing to do) + +# NOTHING TO DO: pure selection-keys widening on an existing column; Odoo's update_db handles. + +l10n_tr_nilvera / res.partner / l10n_tr_nilvera_customer_status (selection): not a function anymore + +# NOTHING TO DO: was a non-stored compute in 18.0 with no column. Stays a non-stored selection in 19.0 (the "not a function anymore" line just indicates the implementation moved off @api.depends but the field signature is unchanged). No schema impact. + +---XML records in module 'l10n_tr_nilvera'--- +NEW ir.actions.server: l10n_tr_nilvera.action_account_reports_customer_statements_do_followup + +# NOTHING TO DO: standard module-data record loaded during install. + +DEL uom.category: l10n_tr_nilvera.product_uom_categ_energy (noupdate) + +# NOTHING TO DO: noupdate-flagged record left in place (standard upgrade flow); database_cleanup handles later.