From cd59025fecc3296c91e1f0441dd85f85aa0b9a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 26 Jun 2013 22:46:51 +0200 Subject: [PATCH] Don't use IN clause to filter invoices In this case, filtering using an IN clause may cost more than just looping over all invoices as the IN clause could be very large. review940002 --- invoice.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/invoice.py b/invoice.py index bdfa717904..1c232a621b 100644 --- a/invoice.py +++ b/invoice.py @@ -606,14 +606,11 @@ class Invoice(Workflow, ModelSQL, ModelView): Currency = pool.get('currency.currency') Date = pool.get('ir.date') - computes = cls.search([ - ('id', 'in', [i.id for i in invoices]), - ('state', '=', 'posted'), - ]) - today = Date.today() res = dict((x.id, _ZERO) for x in invoices) - for invoice in computes: + for invoice in invoices: + if invoice.state != 'posted': + continue amount = _ZERO amount_currency = _ZERO for line in invoice.lines_to_pay: