[FIX] bank statement for cash registers, ending balance checks
authorFabien Pinckaers <fp@tinyerp.com>
Thu, 22 Dec 2011 10:27:03 +0000 (11:27 +0100)
committerFabien Pinckaers <fp@tinyerp.com>
Thu, 22 Dec 2011 10:27:03 +0000 (11:27 +0100)
bzr revid: fp@tinyerp.com-20111222102703-9f6qrj7q1prn000i

addons/account/account_bank_statement.py

index 11e474b..7bb6f3e 100644 (file)
@@ -308,7 +308,7 @@ class account_bank_statement(osv.osv):
 
     def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
         st = self.browse(cr, uid, st_id, context=context)
-        if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001):
+        if not ((abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001) or (abs((st.balance_end or 0.0) - st.balance_end_cash) < 0.0001)):
             raise osv.except_osv(_('Error !'),
                     _('The statement balance is incorrect !\nThe expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end))
         return True
@@ -358,7 +358,10 @@ class account_bank_statement(osv.osv):
                 st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context)
                 self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context)
 
-            self.write(cr, uid, [st.id], {'name': st_number}, context=context)
+            self.write(cr, uid, [st.id], {
+                    'name': st_number,
+                    'balance_end_real': st.balance_end
+            }, context=context)
             self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,))
         return self.write(cr, uid, ids, {'state':'confirm'}, context=context)