From b49be93bd116cffc94c385077d9c497be053ee37 Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Wed, 26 Aug 2026 17:06:13 -0500 Subject: [PATCH] [OU-FIX] base: fix mail.default.from conflict during migration --- .../scripts/base/15.0.1.3/pre-migration.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/openupgrade_scripts/scripts/base/15.0.1.3/pre-migration.py b/openupgrade_scripts/scripts/base/15.0.1.3/pre-migration.py index 31166bf9bd51..a77b70942720 100644 --- a/openupgrade_scripts/scripts/base/15.0.1.3/pre-migration.py +++ b/openupgrade_scripts/scripts/base/15.0.1.3/pre-migration.py @@ -53,6 +53,21 @@ ] +def _fix_icp_mail_default_from(cr): + """Odoo 15 added a new ir.config_parameter key for mail.default.from. + See https://github.com/odoo/odoo/commit/1b9dd118cb0f305ed38b6326fa814336cbf16252 + If a manual record was created in the database, it causes the following error: + DETAIL: Key (key)=(mail.default.from) already exists. + Therefore, the XML ID was added to prevent this error. + """ + cr.execute("SELECT id FROM ir_config_parameter WHERE key = 'mail.default.from'") + res_id = cr.fetchone() + if res_id: + openupgrade.add_xmlid( + cr, "base", "icp_mail_default_from", "ir.config_parameter", res_id[0], True + ) + + @openupgrade.migrate(use_env=False) def migrate(cr, version): """ @@ -69,7 +84,7 @@ def migrate(cr, version): openupgrade.rename_xmlids(cr, rename_xmlids_l10n_ec) openupgrade.rename_xmlids(cr, rename_xmlids_mail) - + _fix_icp_mail_default_from(cr) openupgrade.update_module_names( cr, renamed_modules.items(), environment_namespec=True )