From 78766761145ca9e6fa113165aa411189b249b823 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:04:23 +1000 Subject: [PATCH] Fix plugin pickeling (#5412) (#5457) (cherry picked from commit 1fe382e318e44cfa19b3420d5bff8be941c77102) Co-authored-by: Lukas <76838159+wolflu05@users.noreply.github.com> --- InvenTree/plugin/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/InvenTree/plugin/models.py b/InvenTree/plugin/models.py index 8877997f9a..beeb513465 100644 --- a/InvenTree/plugin/models.py +++ b/InvenTree/plugin/models.py @@ -103,6 +103,12 @@ class PluginConfig(InvenTree.models.MetadataMixin, models.Model): # Save plugin self.plugin: InvenTreePlugin = plugin + def __getstate__(self): + """Customize pickeling behaviour.""" + state = super().__getstate__() + state.pop("plugin", None) # plugin cannot be pickelt in some circumstances when used with drf views, remove it (#5408) + return state + def save(self, force_insert=False, force_update=False, *args, **kwargs): """Extend save method to reload plugins if the 'active' status changes.""" reload = kwargs.pop('no_reload', False) # check if no_reload flag is set