From 28e6d50f08b6cba93539d4db5ca0ca0e4710dccb Mon Sep 17 00:00:00 2001 From: Date: Fri, 27 Apr 2018 09:33:05 +1000 Subject: [PATCH] Check for null StockItem location --- InvenTree/stock/models.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index d60356ea8e..f77550b609 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -181,10 +181,14 @@ class StockItem(models.Model): self.add_stock(-amount) def __str__(self): - return "{n} x {part} @ {loc}".format( - n=self.quantity, - part=self.part.name, - loc=self.location.name) + s = '{n} x {part}'.format( + n=self.quantity, + part=self.part.name) + + if self.location: + s += ' @ {loc}'.format(loc=self.location.name) + + return s @property def is_trackable(self):