From 1794fb8865241e22a5af30020111471ea00a6250 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 16 Nov 2021 00:12:58 +0100 Subject: [PATCH] check if you the plugins really need to be reloaded --- InvenTree/plugin/admin.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/InvenTree/plugin/admin.py b/InvenTree/plugin/admin.py index 16cf3262cc..cef5aa6133 100644 --- a/InvenTree/plugin/admin.py +++ b/InvenTree/plugin/admin.py @@ -9,12 +9,19 @@ import plugin.models as models def plugin_update(queryset, new_status: bool): """general function for bulk changing plugins""" + apps_changed = False + + # run through all plugins in the queryset as the save method needs to be overridden for model in queryset: - model.active = new_status + if model.active is not new_status: + model.active = new_status + apps_changed = True model.save(no_reload=True) - app = apps.get_app_config('plugin') - app.reload_plugins() + # reload plugins if they changed + if apps_changed: + app = apps.get_app_config('plugin') + app.reload_plugins() @admin.action(description='Activate plugin(s)')