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:
@ -522,6 +522,9 @@ class Part(models.Model):
|
|||||||
Part may be stored in multiple locations
|
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']
|
total = self.stock_entries.aggregate(total=Sum('quantity'))['total']
|
||||||
|
|
||||||
if total:
|
if total:
|
||||||
|
Reference in New Issue
Block a user