Account budget reports:Optimized code and bugfixes
bzr revid: jvo@tinyerp.com-20080929073713-701e5q4qc8igfurh
This commit is contained in:
parent
732db12938
commit
1949b8bd99
|
@ -34,34 +34,27 @@ class analytic_account_budget_report(report_sxw.rml_parse):
|
|||
result=[]
|
||||
accounts = self.pool.get('account.analytic.account').browse(self.cr, self.uid, [object.id], self.context.copy())
|
||||
|
||||
c_b_lines_obj=self.pool.get('crossovered.budget.lines')
|
||||
for account_id in accounts:
|
||||
res={}
|
||||
budget_lines=[]
|
||||
b_line_ids=[]
|
||||
|
||||
for line in account_id.crossovered_budget_line:
|
||||
b_line_ids.append(line.id)
|
||||
|
||||
if not b_line_ids:
|
||||
return []
|
||||
|
||||
bd_lines_ids = ','.join([str(x) for x in b_line_ids])
|
||||
|
||||
d_from=form['date_from']
|
||||
d_to=form['date_to']
|
||||
|
||||
query="select id from crossovered_budget_lines where id in ("+ str(bd_lines_ids) + ")"# AND '"+ str(d_from) +"'<=date_from AND date_from<date_to AND date_to<= '"+ str(d_to) +"'"
|
||||
|
||||
self.cr.execute(query)
|
||||
budget_line_ids=self.cr.fetchall()
|
||||
|
||||
if not budget_line_ids:
|
||||
return []
|
||||
|
||||
budget_lines=[x[0] for x in budget_line_ids]
|
||||
|
||||
bd_ids = ','.join([str(x) for x in budget_lines])
|
||||
|
||||
# bd_ids = ','.join([str(x) for x in budget_lines])
|
||||
self.cr.execute('select distinct(crossovered_budget_id) from crossovered_budget_lines where id in (%s)'%(bd_lines_ids))
|
||||
budget_ids=self.cr.fetchall()
|
||||
|
||||
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
|
||||
for i in range(0,len(budget_ids)):
|
||||
|
||||
budget_name=self.pool.get('crossovered.budget').browse(self.cr, self.uid,[budget_ids[i][0]])
|
||||
|
@ -77,17 +70,17 @@ class analytic_account_budget_report(report_sxw.rml_parse):
|
|||
}
|
||||
result.append(res)
|
||||
|
||||
line_ids = self.pool.get('crossovered.budget.lines').search(self.cr, self.uid, [('id', 'in', b_line_ids),('crossovered_budget_id','=',budget_ids[i][0])])
|
||||
line_id = self.pool.get('crossovered.budget.lines').browse(self.cr,self.uid,line_ids)
|
||||
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', b_line_ids),('crossovered_budget_id','=',budget_ids[i][0])])
|
||||
line_id =c_b_lines_obj.browse(self.cr,self.uid,line_ids)
|
||||
tot_theo=tot_pln=tot_prac=tot_perc=0
|
||||
|
||||
done_budget=[]
|
||||
for line in line_id:
|
||||
|
||||
if line.id in budget_lines:
|
||||
if line.id in b_line_ids:
|
||||
theo=pract=0.00
|
||||
theo=line._theo_amt(self.cr, self.uid, [line.id],"theoritical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
|
||||
pract=line._pra_amt(self.cr, self.uid, [line.id],"practical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
|
||||
theo=c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id],context)[line.id]
|
||||
pract=c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id],context)[line.id]
|
||||
|
||||
if line.general_budget_id.id in done_budget:
|
||||
|
||||
|
|
|
@ -75,19 +75,12 @@ class budget_report(report_sxw.rml_parse):
|
|||
for line in budget_id.crossovered_budget_line:
|
||||
budget_ids.append(line.id)
|
||||
|
||||
b_line_ids=','.join([str(x) for x in budget_ids])
|
||||
|
||||
query="select id from crossovered_budget_lines where crossovered_budget_id = '"+ str(budget_id.id) + "'"# AND '"+ str(d_from) +"'<=date_from AND date_from<date_to AND date_to<= '"+ str(d_to) +"'"
|
||||
self.cr.execute(query)
|
||||
budget_line_ids=self.cr.fetchall()
|
||||
|
||||
if not budget_line_ids:
|
||||
if not budget_ids:
|
||||
return []
|
||||
|
||||
budget_lines=[x[0] for x in budget_line_ids]
|
||||
|
||||
bd_ids = ','.join([str(x) for x in budget_lines])
|
||||
b_line_ids=','.join([str(x) for x in budget_ids])
|
||||
|
||||
# bd_ids = ','.join([str(x) for x in budget_lines])
|
||||
self.cr.execute('select distinct(analytic_account_id) from crossovered_budget_lines where id in (%s)'%(b_line_ids))
|
||||
an_ids=self.cr.fetchall()
|
||||
|
||||
|
@ -116,7 +109,7 @@ class budget_report(report_sxw.rml_parse):
|
|||
done_budget=[]
|
||||
for line in line_id:
|
||||
|
||||
if line.id in budget_lines:
|
||||
if line.id in budget_ids:
|
||||
theo=pract=0.00
|
||||
theo=c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id],context)[line.id]
|
||||
pract=c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id],context)[line.id]
|
||||
|
|
Loading…
Reference in New Issue