From bde089f0d9dabb100ada1e02a0abb5b982736d1d Mon Sep 17 00:00:00 2001 From: PierreCookie Date: Tue, 29 Aug 2023 14:53:11 +0200 Subject: [PATCH] trytond: Don't auto_uninstall module Fix #9502 (restore cherry-pick) --- trytond/CHANGELOG | 1 + trytond/trytond/modules/__init__.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index 0938e84f1a3..be644363b66 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -397,6 +397,7 @@ Version 5.0.0 - 2018-10-01 * Rename "install-dependences" into "activate-dependencies" * Use recursive common table expression for child_of/parent_of operators * Add sql_cast on Field +* BUG#9502 Don't auto_uninstall modules Version 4.8.0 - 2018-04-23 -------------------------- diff --git a/trytond/trytond/modules/__init__.py b/trytond/trytond/modules/__init__.py index d6a70a52a5f..9fe622eb032 100644 --- a/trytond/trytond/modules/__init__.py +++ b/trytond/trytond/modules/__init__.py @@ -32,6 +32,8 @@ EGG_MODULES = {} +AUTO_UNINSTALL = os.environ.get('COOG_AUTO_UNINSTALL') + def update_egg_modules(): global EGG_MODULES @@ -415,8 +417,13 @@ def migrate_modules(cursor): if (module_in_db in modules_in_dir or module_in_db in modules_to_migrate): continue - else: + elif AUTO_UNINSTALL: + logger.warning(f'{module_in_db} is about to be uninstalled') modules_to_migrate[module_in_db] = ('to_drop', None) + else: + logger.critical(f'To uninstall {module_in_db} you should set ' + 'COOG_AUTO_UNINSTALL environnement variable') + sys.exit(1) def rename(cursor, table_name, old_name, new_name, var_name): table = Table(table_name)