From ec8699db1773381e3e5d6e999d4dee038d2b993c Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 14 Apr 2017 16:58:49 +0200 Subject: [PATCH] [FIX] account: performance in issued total When a partner has a lot of contacts, the computation of the issue total takes a lot of time. Indeed, it performs the computation for the partner, but also for all the children, despite the fact that the amount is not displayed. opw-726355 --- addons/account/models/partner.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index bb78919c767..8e18962ab00 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -349,12 +349,9 @@ class ResPartner(models.Model): def _compute_issued_total(self): """ Returns the issued total as will be displayed on partner view """ today = fields.Date.context_today(self) - for partner in self: - domain = partner.get_followup_lines_domain(today, overdue_only=True) - issued_total = 0 - for aml in self.env['account.move.line'].search(domain): - issued_total += aml.amount_residual - partner.issued_total = issued_total + domain = self.get_followup_lines_domain(today, overdue_only=True) + for aml in self.env['account.move.line'].search(domain): + aml.partner_id.issued_total += aml.amount_residual @api.one def _compute_has_unreconciled_entries(self):