[FIX] account: fixed the cash statement opening balance problem and some improvement...
authorvra <vra@tinyerp.com>
Tue, 5 Oct 2010 05:57:12 +0000 (11:27 +0530)
committervra <vra@tinyerp.com>
Tue, 5 Oct 2010 05:57:12 +0000 (11:27 +0530)
bzr revid: vra@tinyerp.com-20101005055712-rmbveh0l0k678x1t

addons/account/account_cash_statement.py

index ed987de..34c7510 100644 (file)
@@ -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: