[FIX] account: fixed traceback when emptying the journal of a bank statement

bzr revid: qdp-launchpad@openerp.com-20120925071040-m9054w0qtt26ltjt
This commit is contained in:
Quentin (OpenERP) 2012-09-25 09:10:40 +02:00
parent 773ae0715b
commit 5165bf9c85
1 changed files with 7 additions and 5 deletions

View File

@ -447,11 +447,13 @@ class account_bank_statement(osv.osv):
return self.write(cr, uid, done, {'state':'draft'}, context=context)
def _compute_balance_end_real(self, cr, uid, journal_id, context=None):
cr.execute('SELECT balance_end_real \
FROM account_bank_statement \
WHERE journal_id = %s AND NOT state = %s \
ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
res = cr.fetchone()
res = False
if journal_id:
cr.execute('SELECT balance_end_real \
FROM account_bank_statement \
WHERE journal_id = %s AND NOT state = %s \
ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
res = cr.fetchone()
return res and res[0] or 0.0
def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):