[FIX] account: 'balance' field now uses '_query_get' and uses initial balance
bzr revid: olt@tinyerp.com-20101001125026-m6yabgobzcslok80
This commit is contained in:
parent
a1d54ac584
commit
da504f014e
|
@ -96,8 +96,6 @@ class account_move_line(osv.osv):
|
||||||
else:
|
else:
|
||||||
fiscalperiod_ids = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id','in',fiscalyear_ids)])
|
fiscalperiod_ids = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id','in',fiscalyear_ids)])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#remove from the old query the clause related to the period selection
|
#remove from the old query the clause related to the period selection
|
||||||
res = ''
|
res = ''
|
||||||
count = 1
|
count = 1
|
||||||
|
@ -328,15 +326,27 @@ class account_move_line(osv.osv):
|
||||||
ml = self.browse(cr, uid, id, context)
|
ml = self.browse(cr, uid, id, context)
|
||||||
return map(lambda x: x.id, ml.move_id.line_id)
|
return map(lambda x: x.id, ml.move_id.line_id)
|
||||||
|
|
||||||
# TODO: this is false, it does not uses draft and closed periods
|
def _balance(self, cr, uid, ids, name, arg, context=None):
|
||||||
def _balance(self, cr, uid, ids, prop, unknow_none, unknow_dict):
|
if context is None:
|
||||||
res={}
|
context = {}
|
||||||
# TODO group the foreach in sql
|
|
||||||
for id in ids:
|
c = context.copy()
|
||||||
cr.execute('SELECT date,account_id FROM account_move_line WHERE id=%s', (id,))
|
c['initital_bal'] = True
|
||||||
dt, acc = cr.fetchone()
|
|
||||||
cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE account_id=%s AND (date<%s OR (date=%s AND id<=%s))', (acc,dt,dt,id))
|
sql = [
|
||||||
res[id] = cr.fetchone()[0]
|
"""select l2.id, sum(l1.debit-l1.credit) from account_move_line l1, account_move_line l2""",
|
||||||
|
"""where l2.account_id=l1.account_id""",
|
||||||
|
"""and""",
|
||||||
|
"""l1.id<=l2.id""",
|
||||||
|
"""and""",
|
||||||
|
"""l2.id in %s""",
|
||||||
|
"""and""",
|
||||||
|
self._query_get(cr, uid, obj='l1', context=c),
|
||||||
|
""" group by l2.id""",
|
||||||
|
]
|
||||||
|
|
||||||
|
cr.execute('\n'.join(sql), [tuple(ids)])
|
||||||
|
res = dict(cr.fetchall())
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _invoice(self, cursor, user, ids, name, arg, context=None):
|
def _invoice(self, cursor, user, ids, name, arg, context=None):
|
||||||
|
|
Loading…
Reference in New Issue