From edf6dbd439286c1f5d0d33a4ea8dd3526415c476 Mon Sep 17 00:00:00 2001 From: vra Date: Tue, 5 Oct 2010 11:27:12 +0530 Subject: [PATCH] [FIX] account: fixed the cash statement opening balance problem and some improvement at cancel side. bzr revid: vra@tinyerp.com-20101005055712-rmbveh0l0k678x1t --- addons/account/account_cash_statement.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index ed987de7e37..34c751072ce 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -250,6 +250,12 @@ class account_cash_statement(osv.osv): if self.pool.get('account.journal').browse(cr, uid, vals['journal_id']).type == 'cash': open_close = self._get_cash_open_close_box_lines(cr, uid, context) + if vals.get('starting_details_ids',False): + for start in vals.get('starting_details_ids'): + dict_val = start[2] + for end in open_close['end']: + if end[2]['pieces'] == dict_val['pieces']: + end[2]['number'] += dict_val['number'] vals.update({ 'ending_details_ids':open_close['start'], 'starting_details_ids':open_close['end'] @@ -260,7 +266,7 @@ class account_cash_statement(osv.osv): 'starting_details_ids':False }) res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context) - #self.write(cr, uid, [res_id], {}) + self.write(cr, uid, [res_id], {}) return res_id def write(self, cr, uid, ids, vals, context=None): @@ -370,6 +376,14 @@ class account_cash_statement(osv.osv): super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context) return self.write(cr, uid, ids, {'closing_date':time.strftime("%Y-%m-%d %H:%M:%S")}, context=context) + def button_cancel(self, cr, uid, ids, context=None): + cash_box_line_pool = self.pool.get('account.cashbox.line') + super(account_cash_statement, self).button_cancel(cr, uid, ids, context=context) + for st in self.browse(cr, uid, ids, context): + for end in st.ending_details_ids: + cash_box_line_pool.write(cr, uid, [end.id], {'number':0}) + return True + account_cash_statement() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: