From f737f90c89234ecedcaade8cf20c0eee01a2ce73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Sun, 15 Nov 2015 12:48:14 -0300 Subject: [PATCH] Remove useless join in get_deposit_balance issue5082 review24541002 --- party.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/party.py b/party.py index f3ffb59d07..7abda31df2 100644 --- a/party.py +++ b/party.py @@ -97,20 +97,15 @@ class Party: 'Return the deposit account balance (debit - credit) for the party' pool = Pool() MoveLine = pool.get('account.move.line') - Account = pool.get('account.account') cursor = Transaction().cursor line = MoveLine.__table__() - account = Account.__table__() - assert deposit_account.kind == 'deposit' cursor.lock(MoveLine._table) - - cursor.execute(*line.join(account, condition=account.id == line.account - ).select( + cursor.execute(*line.select( Sum(Coalesce(line.debit, 0) - Coalesce(line.credit, 0)), - where=(account.id == deposit_account.id) + where=(line.account == deposit_account.id) & (line.party == self.id) & (line.reconciliation == Null))) amount, = cursor.fetchone()