From 15a0d260f8d9426ba07b94a140bbd415c851dada Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 18 Nov 2021 23:15:40 +1100 Subject: [PATCH] Handle case where user is not specified --- InvenTree/stock/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 909900a0b4..0c045f1cf5 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -72,7 +72,7 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView): def get_serializer_context(self): ctx = super().get_serializer_context() - ctx['user'] = self.request.user + ctx['user'] = getattr(self.request, 'user', None) return ctx @@ -392,7 +392,7 @@ class StockList(generics.ListCreateAPIView): def get_serializer_context(self): ctx = super().get_serializer_context() - ctx['user'] = self.request.user + ctx['user'] = getattr(self.request, 'user', None) return ctx