[FIX] Rewrite the sql query
lp bug: https://launchpad.net/bugs/321958 fixed bzr revid: stephane@tinyerp.com-20090127181043-bas7sgjwexwiqbb1
This commit is contained in:
parent
6387d2807e
commit
61ad151002
|
@ -159,7 +159,7 @@ class crossovered_budget_lines(osv.osv):
|
||||||
def _prac_amt(self, cr, uid, ids,context={}):
|
def _prac_amt(self, cr, uid, ids,context={}):
|
||||||
res = {}
|
res = {}
|
||||||
for line in self.browse(cr, uid, ids):
|
for line in self.browse(cr, uid, ids):
|
||||||
acc_ids = ','.join([str(x.id) for x in line.general_budget_id.account_ids])
|
acc_ids = [x.id for x in line.general_budget_id.account_ids]
|
||||||
if not acc_ids:
|
if not acc_ids:
|
||||||
raise osv.except_osv('Error!',"The General Budget '" + str(line.general_budget_id.name) + "' has no Accounts!" )
|
raise osv.except_osv('Error!',"The General Budget '" + str(line.general_budget_id.name) + "' has no Accounts!" )
|
||||||
date_to = line.date_to
|
date_to = line.date_to
|
||||||
|
@ -168,9 +168,11 @@ class crossovered_budget_lines(osv.osv):
|
||||||
date_from = context['wizard_date_from']
|
date_from = context['wizard_date_from']
|
||||||
if context.has_key('wizard_date_to'):
|
if context.has_key('wizard_date_to'):
|
||||||
date_to = context['wizard_date_to']
|
date_to = context['wizard_date_to']
|
||||||
cr.execute("select sum(amount) from account_analytic_line where account_id=%s and (date between to_date(%s,'yyyy-mm-dd') and to_date(%s,'yyyy-mm-dd')) and general_account_id in (%s)", (line.analytic_account_id.id,date_from,date_to,acc_ids))
|
cr.execute("select sum(amount) from account_analytic_line where account_id=%%s and (date "
|
||||||
|
"between to_date(%%s,'yyyy-mm-dd') and to_date(%%s,'yyyy-mm-dd')) and "
|
||||||
|
"general_account_id in (%s)" % ",".join(['%s']*len(acc_ids)), (line.analytic_account_id.id,date_from,date_to,acc_ids))
|
||||||
result = cr.fetchone()[0]
|
result = cr.fetchone()[0]
|
||||||
if result==None:
|
if result is None:
|
||||||
result = 0.00
|
result = 0.00
|
||||||
res[line.id] = result
|
res[line.id] = result
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue