[FIX] analytic: chart of analytic accounts crashing in some use cases

lp bug: https://launchpad.net/bugs/933411 fixed

bzr revid: qdp-launchpad@openerp.com-20120216180111-1sfod39gvj1387eq
This commit is contained in:
Quentin (OpenERP) 2012-02-16 19:01:11 +01:00
parent e0d52f4525
commit 0f500c57d9
1 changed files with 7 additions and 5 deletions

View File

@ -47,14 +47,14 @@ class account_analytic_account(osv.osv):
recres[account.id] = recursive_computation(account) recres[account.id] = recursive_computation(account)
return recres return recres
def _debit_credit_bal_qtty(self, cr, uid, ids, name, arg, context=None): def _debit_credit_bal_qtty(self, cr, uid, ids, fields, arg, context=None):
res = {} res = {}
if context is None: if context is None:
context = {} context = {}
child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
for i in child_ids: for i in child_ids:
res[i] = {} res[i] = {}
for n in name: for n in fields:
res[i][n] = 0.0 res[i][n] = 0.0
if not child_ids: if not child_ids:
@ -89,9 +89,11 @@ class account_analytic_account(osv.osv):
WHERE a.id IN %s WHERE a.id IN %s
""" + where_date + """ """ + where_date + """
GROUP BY a.id""", where_clause_args) GROUP BY a.id""", where_clause_args)
for ac_id, debit, credit, balance, quantity in cr.fetchall(): for row in cr.dictfetchall():
res[ac_id] = {'debit': debit, 'credit': credit, 'balance': balance, 'quantity': quantity} res[row['id']] = {}
return self._compute_level_tree(cr, uid, ids, child_ids, res, ['debit', 'credit', 'balance', 'quantity'], context) for field in fields:
res[row['id']][field] = row[field]
return self._compute_level_tree(cr, uid, ids, child_ids, res, fields, context)
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
if not ids: if not ids: