[IMP]:account_budget sql queries to parameterized query
bzr revid: nch@tinyerp.com-20091127113513-5utkqwss17vjh7yy
This commit is contained in:
parent
27823255c1
commit
23874d7282
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@ class account_budget_post(osv.osv):
|
||||||
'account_ids': fields.many2many('account.account', 'account_budget_rel', 'budget_id', 'account_id', 'Accounts'),
|
'account_ids': fields.many2many('account.account', 'account_budget_rel', 'budget_id', 'account_id', 'Accounts'),
|
||||||
'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'general_budget_id', 'Budget Lines'),
|
'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'general_budget_id', 'Budget Lines'),
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||||
'sequence': fields.integer('Sequence'),
|
'sequence': fields.integer('Sequence'),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'sequence': lambda *a: 1,
|
'sequence': lambda *a: 1,
|
||||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||||
}
|
}
|
||||||
_order = "sequence, name"
|
_order = "sequence, name"
|
||||||
|
|
||||||
def spread(self, cr, uid, ids, fiscalyear_id=False, amount=0.0):
|
def spread(self, cr, uid, ids, fiscalyear_id=False, amount=0.0):
|
||||||
dobj = self.pool.get('account.budget.post.dotation')
|
dobj = self.pool.get('account.budget.post.dotation')
|
||||||
|
@ -76,8 +76,10 @@ class account_budget_post_dotation(osv.osv):
|
||||||
|
|
||||||
total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start)
|
total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start)
|
||||||
budget_id=line.post_id and line.post_id.id or False
|
budget_id=line.post_id and line.post_id.id or False
|
||||||
query="select id from crossovered_budget_lines where general_budget_id= '"+ str(budget_id) + "' AND (date_from >='" +obj_period.date_start +"' and date_from <= '"+obj_period.date_stop + "') OR (date_to >='" +obj_period.date_start +"' and date_to <= '"+obj_period.date_stop + "') OR (date_from <'" +obj_period.date_start +"' and date_to > '"+obj_period.date_stop + "')"
|
query="select id from crossovered_budget_lines where \
|
||||||
cr.execute(query)
|
general_budget_id= %s AND (date_from >=%s and date_from <= %s ) \
|
||||||
|
OR (date_to >=%s and date_to <= %s) OR (date_from < %s and date_to > %s)"
|
||||||
|
cr.execute(query,(budget_id,obj_period.date_start,obj_period.date_stop,obj_period.date_start,obj_period.date_stop,obj_period.date_start,obj_period.date_stop,))
|
||||||
res1=cr.fetchall()
|
res1=cr.fetchall()
|
||||||
|
|
||||||
tot_planned=0.00
|
tot_planned=0.00
|
||||||
|
@ -175,10 +177,9 @@ 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 "
|
||||||
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 "
|
||||||
"between to_date(%%s,'yyyy-mm-dd') and to_date(%%s,'yyyy-mm-dd')) and "
|
"general_account_id=ANY(%s)", (line.analytic_account_id.id, date_from, date_to,acc_ids,))
|
||||||
"general_account_id in (%s)" % ",".join(map(str,acc_ids)), (line.analytic_account_id.id, date_from, date_to ))
|
|
||||||
result = cr.fetchone()[0]
|
result = cr.fetchone()[0]
|
||||||
if result is None:
|
if result is None:
|
||||||
result = 0.00
|
result = 0.00
|
||||||
|
@ -213,7 +214,7 @@ class crossovered_budget_lines(osv.osv):
|
||||||
elapsed = min(strToDate(line.date_to),strToDate(date_to)) - max(strToDate(line.date_from),strToDate(date_from))
|
elapsed = min(strToDate(line.date_to),strToDate(date_to)) - max(strToDate(line.date_from),strToDate(date_from))
|
||||||
if strToDate(date_to) < strToDate(line.date_from):
|
if strToDate(date_to) < strToDate(line.date_from):
|
||||||
elapsed = strToDate(date_to) - strToDate(date_to)
|
elapsed = strToDate(date_to) - strToDate(date_to)
|
||||||
|
|
||||||
if total.days:
|
if total.days:
|
||||||
theo_amt = float(elapsed.days/float(total.days))*line.planned_amount
|
theo_amt = float(elapsed.days/float(total.days))*line.planned_amount
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -65,13 +65,11 @@ class analytic_account_budget_report(report_sxw.rml_parse):
|
||||||
if not b_line_ids:
|
if not b_line_ids:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
bd_lines_ids = ','.join([str(x) for x in b_line_ids])
|
|
||||||
|
|
||||||
d_from=form['date_from']
|
d_from=form['date_from']
|
||||||
d_to=form['date_to']
|
d_to=form['date_to']
|
||||||
|
|
||||||
# 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))
|
self.cr.execute('select distinct(crossovered_budget_id) from crossovered_budget_lines where id =ANY(%s)',(b_line_ids,))
|
||||||
budget_ids=self.cr.fetchall()
|
budget_ids=self.cr.fetchall()
|
||||||
|
|
||||||
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
|
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -71,10 +71,8 @@ class budget_report(report_sxw.rml_parse):
|
||||||
if not budget_ids:
|
if not budget_ids:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
b_line_ids=','.join([str(x) for x in budget_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(analytic_account_id) from crossovered_budget_lines where id in (%s)'%(b_line_ids))
|
self.cr.execute('select distinct(analytic_account_id) from crossovered_budget_lines where id =ANY(%s)',(budget_ids,))
|
||||||
an_ids=self.cr.fetchall()
|
an_ids=self.cr.fetchall()
|
||||||
|
|
||||||
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
|
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
|
||||||
|
|
Loading…
Reference in New Issue