mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Calculate stock based on variant stock if part is a template
This commit is contained in:
parent
c45a506a10
commit
7881a67db4
@ -522,7 +522,10 @@ class Part(models.Model):
|
||||
Part may be stored in multiple locations
|
||||
"""
|
||||
|
||||
total = self.stock_entries.aggregate(total=Sum('quantity'))['total']
|
||||
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:
|
||||
return total
|
||||
|
Loading…
Reference in New Issue
Block a user