From 87edbf7c334497d985d3e5dcd3743fe48bac11cf Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 15 Nov 2021 01:01:55 +0100 Subject: [PATCH] unresgister models when deactivating --- InvenTree/plugin/apps.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/plugin/apps.py b/InvenTree/plugin/apps.py index e60de35833..40c021dc1e 100644 --- a/InvenTree/plugin/apps.py +++ b/InvenTree/plugin/apps.py @@ -207,6 +207,14 @@ class PluginAppConfig(AppConfig): return plugin_path def deactivate_integration_app(self): + # unregister models from admin + for app_name in settings.INTEGRATION_APPS_PATHS: + for model in apps.get_app_config(app_name.split('.')[-1]).get_models(): + try: + admin.site.unregister(model) + except: + pass + # remove plugin from installed_apps for plugin in settings.INTEGRATION_APPS_PATHS: settings.INSTALLED_APPS.remove(plugin)