2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 03:55:41 +00:00

More fixes

This commit is contained in:
Oliver Walters
2021-04-20 10:59:28 +10:00
parent 6b9145ae56
commit 0fbf39f1bc
3 changed files with 30 additions and 5 deletions

View File

@ -1163,7 +1163,16 @@ class Part(MPTTModel):
Return the total amount of this part allocated to build orders
"""
query = self.build_order_allocations().aggregate(total=Coalesce(Sum('quantity'), 0))
query = self.build_order_allocations().aggregate(
total=Coalesce(
Sum(
'quantity',
output_field=models.DecimalField()
),
0,
output_field=models.DecimalField(),
)
)
return query['total']
@ -1179,7 +1188,16 @@ class Part(MPTTModel):
Return the tutal quantity of this part allocated to sales orders
"""
query = self.sales_order_allocations().aggregate(total=Coalesce(Sum('quantity'), 0))
query = self.sales_order_allocations().aggregate(
total=Coalesce(
Sum(
'quantity',
output_field=models.DecimalField(),
),
0,
output_field=models.DecimalField(),
)
)
return query['total']
@ -1194,7 +1212,6 @@ class Part(MPTTModel):
self.build_order_allocation_count(),
self.sales_order_allocation_count(),
],
output_field=models.DecimalField()
)
def stock_entries(self, include_variants=True, in_stock=None):