From bc68019ddff296f192d2c17ef31a9b80099d991c Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Mon, 11 Feb 2013 11:00:17 +0100 Subject: [PATCH] [FIX] improve sql query --- account_cancel_invoice_check_voucher/account_invoice.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/account_cancel_invoice_check_voucher/account_invoice.py b/account_cancel_invoice_check_voucher/account_invoice.py index faaf69335..91112c334 100644 --- a/account_cancel_invoice_check_voucher/account_invoice.py +++ b/account_cancel_invoice_check_voucher/account_invoice.py @@ -38,9 +38,11 @@ class account_invoice(orm.TransientModel): FROM account_bank_statement_line AS absl INNER JOIN account_bank_statement AS abs ON absl.statement_id = abs.id - WHERE voucher_id IN - ( SELECT voucher_id FROM account_voucher_line WHERE move_line_id IN - (SELECT id FROM account_move_line WHERE move_id = %s )) LIMIT 1""", + WHERE EXISTS (SELECT 1 + FROM account_voucher_line JOIN account_move_line ON + (account_voucher_line.move_line_id = account_move_line.id) + WHERE voucher_id=absl.voucher_id + AND account_move_line.move_id = %s )""", (invoice['move_id'][0],)) statement_lines = cr.dictfetchone() if statement_lines: