From a12849e94295ecb2216cc8b8886ed0ca43348487 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 26 May 2026 10:53:27 +0200 Subject: [PATCH] [FIX] loyalty: incomplete migration --- docsource/modules180-190.rst | 2 +- .../loyalty/19.0.1.0/post-migration.py | 9 +----- .../scripts/loyalty/19.0.1.0/pre-migration.py | 29 +++++++++++++++++++ .../19.0.1.0/upgrade_analysis_work.txt | 7 +++++ 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 openupgrade_scripts/scripts/loyalty/19.0.1.0/pre-migration.py create mode 100644 openupgrade_scripts/scripts/loyalty/19.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules180-190.rst b/docsource/modules180-190.rst index e7f797ce0766..998d7e667d81 100644 --- a/docsource/modules180-190.rst +++ b/docsource/modules180-190.rst @@ -698,7 +698,7 @@ Module coverage 18.0 -> 19.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | link_tracker | |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| loyalty | | | +| loyalty |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | lunch | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/loyalty/19.0.1.0/post-migration.py b/openupgrade_scripts/scripts/loyalty/19.0.1.0/post-migration.py index c5607dd9ad40..41660e77d70d 100644 --- a/openupgrade_scripts/scripts/loyalty/19.0.1.0/post-migration.py +++ b/openupgrade_scripts/scripts/loyalty/19.0.1.0/post-migration.py @@ -3,11 +3,4 @@ @openupgrade.migrate() def migrate(env, version): - """Reset "lang" field for these records, as they were set in previous - version in XML, but not in this one, and Odoo doesn't reset non present - fields. - """ - for xmlid in ("mail_template_gift_card", "mail_template_loyalty_card"): - template = env.ref(f"loyalty.{xmlid}", False) - if template: - template.lang = False + openupgrade.load_data(env, "loyalty", "19.0.1.0/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/loyalty/19.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/loyalty/19.0.1.0/pre-migration.py new file mode 100644 index 000000000000..1583a718c4ae --- /dev/null +++ b/openupgrade_scripts/scripts/loyalty/19.0.1.0/pre-migration.py @@ -0,0 +1,29 @@ +from openupgradelib import openupgrade + + +def fix_template_lang(env): + """Reset "lang" field for these records, as they were set in previous + version in XML, but not in this one, and Odoo doesn't reset non present + fields. + The templates are not marked as noupdate, so this change is not caught by + upgrade_analysis + """ + env.cr.execute( + """ + UPDATE mail_template + SET lang=NULL + FROM + ir_model_data imd + WHERE + imd.module='loyalty' and imd.name in ( + 'mail_template_gift_card', + 'mail_template_loyalty_card' + ) + and mail_template.id=imd.res_id + """ + ) + + +@openupgrade.migrate() +def migrate(env, version): + fix_template_lang(env) diff --git a/openupgrade_scripts/scripts/loyalty/19.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/loyalty/19.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..0dd7977ea42c --- /dev/null +++ b/openupgrade_scripts/scripts/loyalty/19.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,7 @@ +---Models in module 'loyalty'--- +---Fields in module 'loyalty'--- +loyalty / loyalty.reward / tax_ids (many2many) : DEL relation: account.tax + +# NOTHING TO DO + +---XML records in module 'loyalty'---