Check for null StockItem location

This commit is contained in:
2018-04-27 09:33:05 +10:00
parent 5162c1d11f
commit 28e6d50f08

View File

@ -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):