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
This commit is contained in:
1 parent
8b3872a7b3
commit
cd59025fec
1 file changed
+3
-6
+3
-6
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user