From d09e09100c89beaec7f547fd1c42ed542035d8f1 Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Thu, 20 Oct 2022 10:15:32 +0200 Subject: [PATCH] [FIX] base: Uninstall l10n_it_edi to avoid conflict with l10n_it_fatturapa --- .../scripts/base/14.0.1.3/end-migration.py | 15 +++++++++++++++ .../scripts/base/14.0.1.3/pre-migrate.py | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/openupgrade_scripts/scripts/base/14.0.1.3/end-migration.py b/openupgrade_scripts/scripts/base/14.0.1.3/end-migration.py index 59a0a91bd9c5..3e33c7eb8810 100644 --- a/openupgrade_scripts/scripts/base/14.0.1.3/end-migration.py +++ b/openupgrade_scripts/scripts/base/14.0.1.3/end-migration.py @@ -3,6 +3,20 @@ from openupgradelib import openupgrade +def uninstall_conflicting_it_edi(cr): + it_edi_conflicting_modules = ("l10n_it_edi", "l10n_it_fatturapa") + if all( + openupgrade.is_module_installed(cr.cr, m) for m in it_edi_conflicting_modules + ): + it_edi_module = cr["ir.module.module"].search( + [ + ("name", "=", "l10n_it_edi"), + ], + limit=1, + ) + it_edi_module.button_uninstall() + + @openupgrade.migrate() def migrate(env, version): """Call disable_invalid_filters in every edition of openupgrade""" @@ -14,3 +28,4 @@ def migrate(env, version): openupgrade.update_module_names( env.cr, [("web_diagram", "web")], merge_modules=True ) + uninstall_conflicting_it_edi(env) diff --git a/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py b/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py index 777a963e5625..57b7a4ecdf5d 100644 --- a/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py +++ b/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py @@ -87,6 +87,20 @@ def deduplicate_ir_properties(cr): ) +def uninstall_conflicting_it_edi(cr): + it_edi_conflicting_modules = ("l10n_it_edi", "l10n_it_fatturapa") + if all(openupgrade.is_module_installed(cr, m) for m in it_edi_conflicting_modules): + # Mark as 'to_remove' to avoid raising a conflict; it will be installed anyway, + # but we will uninstall it for good in end-migration. + openupgrade.logged_query( + cr, + """ + UPDATE ir_module_module + SET state='to remove' + WHERE name = 'l10n_it_edi'""", + ) + + @openupgrade.migrate(use_env=False) def migrate(cr, version): """ @@ -125,6 +139,7 @@ def migrate(cr, version): # Perform module renames and merges openupgrade.update_module_names(cr, renamed_modules.items()) openupgrade.update_module_names(cr, merged_modules.items(), merge_modules=True) + uninstall_conflicting_it_edi(cr) # Migrate partners from Fil to Tagalog # See https://github.com/odoo/odoo/commit/194ed76c5cc9 openupgrade.logged_query(