MEJORA: Fix N+1 query problems in project_list and export_expenses_csv
This commit is contained in:
@@ -83,6 +83,8 @@ class Project(CatalogModel):
|
||||
|
||||
@property
|
||||
def total_expenses_clp(self):
|
||||
if hasattr(self, 'total_expenses'):
|
||||
return self.total_expenses or Decimal('0.00')
|
||||
return self.expenses.aggregate(total=models.Sum('amount_clp'))['total'] or Decimal('0.00')
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user