mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 16:32:15 +00:00
Fix for postgres requring an explicit definition of what the output field type is with summing mixed fields
This commit is contained in:
@@ -297,7 +297,9 @@ class Event(models.Model, RevisionMixin):
|
|||||||
#total = 0.0
|
#total = 0.0
|
||||||
#for item in self.items.filter(cost__gt=0).extra(select="SUM(cost * quantity) AS sum"):
|
#for item in self.items.filter(cost__gt=0).extra(select="SUM(cost * quantity) AS sum"):
|
||||||
# total += item.sum
|
# total += item.sum
|
||||||
total = EventItem.objects.filter(event=self).aggregate(sum_total=models.Sum(models.F('cost')*models.F('quantity')))['sum_total']
|
total = EventItem.objects.filter(event=self).aggregate(
|
||||||
|
sum_total=models.Sum(models.F('cost')*models.F('quantity'), output_field=models.DecimalField(max_digits=10, decimal_places=2))
|
||||||
|
)['sum_total']
|
||||||
if total:
|
if total:
|
||||||
return total
|
return total
|
||||||
return Decimal("0.00")
|
return Decimal("0.00")
|
||||||
|
|||||||
Reference in New Issue
Block a user