|
|
|
@ -19,7 +19,7 @@ class Account(models.Model): |
|
|
|
"""Adjust the ballance according to the sales, |
|
|
|
without saving the model.""" |
|
|
|
self.balance = Sale.objects.filter(account=self)\ |
|
|
|
.aggregate(models.Sum('price'))['price__sum'] |
|
|
|
.aggregate(models.Sum('price'))['price__sum'] or 0 |
|
|
|
|
|
|
|
|
|
|
|
class Sale(models.Model): |
|
|
|
|