From f7abc746493a81212989deccaadda6c9dd086a57 Mon Sep 17 00:00:00 2001 From: Don Kendall Date: Thu, 21 May 2026 19:46:27 -0400 Subject: [PATCH] [OU-FIX] loyalty: pre-migrate stale `_get_mail_partner` in stored mail.template.lang MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 18.0 loyalty `mail_template_gift_card` and `mail_template_loyalty_card` both store `lang` as `{{ object._get_mail_partner().lang }}`. The method was renamed to `_get_mail_author` in 19.0 — when the 19.0 module update re-renders `lang` during data load, it raises AttributeError and aborts the migration at `loyalty/data/mail_template_data.xml:3` before the existing post-migration (which nulls `lang`) ever runs. Pre-migration is the only safe place to fix this; rename in place via REPLACE so the rendering check passes and the existing post-migration (or any user customization of `lang`) keeps working. --- docsource/modules180-190.rst | 2 +- .../scripts/loyalty/19.0.1.0/pre-migration.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/loyalty/19.0.1.0/pre-migration.py diff --git a/docsource/modules180-190.rst b/docsource/modules180-190.rst index e7f797ce076..998d7e667d8 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/pre-migration.py b/openupgrade_scripts/scripts/loyalty/19.0.1.0/pre-migration.py new file mode 100644 index 00000000000..3c5e6439bf1 --- /dev/null +++ b/openupgrade_scripts/scripts/loyalty/19.0.1.0/pre-migration.py @@ -0,0 +1,18 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + """Rename the removed ``_get_mail_partner`` helper to ``_get_mail_author`` + in the stored ``lang`` of these templates, as the 19.0 data-load render + aborts before the existing post-migration could clear the field. + """ + openupgrade.logged_query( + env.cr, + """ + UPDATE mail_template + SET lang = REPLACE(lang, '_get_mail_partner', '_get_mail_author') + WHERE model = 'loyalty.card' + AND lang LIKE '%%_get_mail_partner%%' + """, + )