summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorvra <vra@tinyerp.com>2010-09-03 16:55:45 +0530
committervra <vra@tinyerp.com>2010-09-03 16:55:45 +0530
commit4fd67b69c6b0fc3ce35920df8e8fdc664e1fbc7b (patch)
tree68ede5e52d06b4577262dbedfa585a08aca3ebe2 /addons
parentcd43bf49df07ba685838b968713a93a94ec2a2a6 (diff)
[FIX] account: Fixed the opening balance problem in account_cash_statement.
bzr revid: vra@tinyerp.com-20100903112545-78hgv1gy6gayvvvt
Diffstat (limited to 'addons')
-rw-r--r--addons/account/account_cash_statement.py70
1 files changed, 45 insertions, 25 deletions
diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py
index 5ed057536a8..5010664e8f2 100644
--- a/addons/account/account_cash_statement.py
+++ b/addons/account/account_cash_statement.py
@@ -151,17 +151,17 @@ class account_cash_statement(osv.osv):
res[r] = round(res[r], 2)
return res
- def _get_company(self, cr, uid, ids, context={}):
+ def _get_company(self, cr, uid, context={}):
user_pool = self.pool.get('res.users')
company_pool = self.pool.get('res.company')
- user = user_pool.browse(cr, uid, uid, uid)
+ user = user_pool.browse(cr, uid, uid, context)
company_id = user.company_id and user.company_id.id
if not company_id:
company_id = company_pool.search(cr, uid, [])[0]
return company_id
- def _get_cash_open_box_lines(self, cr, uid, ids, context={}):
+ def _get_cash_open_box_lines(self, cr, uid, context={}):
res = []
curr = [1, 2, 5, 10, 20, 50, 100, 500]
for rs in curr:
@@ -170,9 +170,18 @@ class account_cash_statement(osv.osv):
'number':0
}
res.append(dct)
+ journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','cash')], context=context)
+ if journal_ids:
+ results = self.search(cr, uid, [('journal_id','in',journal_ids),('state','=','confirm')],context=context)
+ if results:
+ cash_st = self.browse(cr, uid, results, context)[0]
+ for cash_line in cash_st.ending_details_ids:
+ for r in res:
+ if cash_line.pieces == r['pieces']:
+ r['number'] = cash_line.number
return res
- def _get_cash_close_box_lines(self, cr, uid, ids, context={}):
+ def _get_default_cash_close_box_lines(self, cr, uid, context={}):
res = []
curr = [1, 2, 5, 10, 20, 50, 100, 500]
for rs in curr:
@@ -180,7 +189,18 @@ class account_cash_statement(osv.osv):
'pieces':rs,
'number':0
}
- res.append((0, 0, dct))
+ res.append(dct)
+ return res
+
+ def _get_cash_close_box_lines(self, cr, ids, uid, context={}):
+ res = []
+ curr = [1, 2, 5, 10, 20, 50, 100, 500]
+ for rs in curr:
+ dct = {
+ 'pieces':rs,
+ 'number':0
+ }
+ res.append((0,0,dct))
return res
_columns = {
@@ -206,7 +226,7 @@ class account_cash_statement(osv.osv):
'user_id': lambda self, cr, uid, context=None: uid,
'company_id': _get_company,
'starting_details_ids':_get_cash_open_box_lines,
- 'ending_details_ids':_get_cash_open_box_lines
+ 'ending_details_ids':_get_default_cash_close_box_lines
}
def create(self, cr, uid, vals, context=None):
@@ -305,25 +325,25 @@ class account_cash_statement(osv.osv):
'name': number
})
- cr.execute("select id from account_bank_statement where journal_id=%s and user_id=%s and state=%s order by id desc limit 1", (statement.journal_id.id, uid, 'confirm'))
- rs = cr.fetchone()
- rs = rs and rs[0] or None
- if rs:
- if len(statement.starting_details_ids) > 0:
- sid = []
- for line in statement.starting_details_ids:
- sid.append(line.id)
- cash_pool.unlink(cr, uid, sid)
-
- statement = statement_pool.browse(cr, uid, rs)
- balance_start = statement.balance_end_real or 0.0
- open_ids = cash_pool.search(cr, uid, [('ending_id','=',statement.id)])
- for sid in open_ids:
- default = {
- 'ending_id': False,
- 'starting_id':ids[0]
- }
- cash_pool.copy(cr, uid, sid, default)
+# cr.execute("select id from account_bank_statement where journal_id=%s and user_id=%s and state=%s order by id desc limit 1", (statement.journal_id.id, uid, 'confirm'))
+# rs = cr.fetchone()
+# rs = rs and rs[0] or None
+# if rs:
+# if len(statement.starting_details_ids) > 0:
+# sid = []
+# for line in statement.starting_details_ids:
+# sid.append(line.id)
+# cash_pool.unlink(cr, uid, sid)
+#
+# statement = statement_pool.browse(cr, uid, rs)
+# balance_start = statement.balance_end_real or 0.0
+# open_ids = cash_pool.search(cr, uid, [('ending_id','=',statement.id)])
+# for sid in open_ids:
+# default = {
+# 'ending_id': False,
+# 'starting_id':ids[0]
+# }
+# cash_pool.copy(cr, uid, sid, default)
vals.update({
'date':time.strftime("%Y-%m-%d %H:%M:%S"),