2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 11:35:41 +00:00

Calculate stock based on variant stock if part is a template

This commit is contained in:
Oliver Walters
2019-05-26 00:01:01 +10:00
parent c45a506a10
commit 7881a67db4

View File

@ -522,6 +522,9 @@ class Part(models.Model):
Part may be stored in multiple locations
"""
if self.is_template:
total = sum([variant.total_stock for variant in self.variants.all()])
else:
total = self.stock_entries.aggregate(total=Sum('quantity'))['total']
if total: