Improve on change on start balance:

* use search instead af sql query
* fix : filter on journal
This commit is contained in:
Bertrand Chenal committed 2008-06-17 11:44:14 +02:00
1 parent 20bff133b6
commit ef8babae0b
1 file changed
+4 -3
+4 -3
View File
@@ -41,9 +41,10 @@ class Statement(OSV):
def on_change_journal(self, cursor, user, ids, value, context=None):
if not value.get('journal'):
return {}
cursor.execute('SELECT end_balance FROM statement_statement '\
'ORDER BY date DESC limit 1')
if not cursor.rowcount:
statement_ids = self.search(
cursor, user, [('journal', '=', value['journal'])],
order=[('date','DESC')], limit=1, context=context)
if not statement_ids:
return {}
return {'start_balance': cursor.fetchone()[0]}