mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-05 18:01:14 +00:00
Calculate stock based on variant stock if part is a template
This commit is contained in:
1 parent
c45a506a10
commit
7881a67db4
1 file changed
+3
@@ -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