From 9da3063328622dad36efb2c41d40a5ab3399128e Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Mon, 23 Nov 2009 17:19:56 +0530 Subject: [PATCH] [IMP]:scrum modules sql queries to parameterized query bzr revid: nch@tinyerp.com-20091123114956-lr17g8i6fjp74o4e --- addons/scrum/report/_burndown.py | 11 +++++------ addons/scrum/report/task_burndown.py | 13 +++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/addons/scrum/report/_burndown.py b/addons/scrum/report/_burndown.py index f0ccc51cc95..fc7b60437ae 100644 --- a/addons/scrum/report/_burndown.py +++ b/addons/scrum/report/_burndown.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -26,14 +26,13 @@ import time def compute_burndown(cr, uid, tasks_id, date_start, date_stop): latest = False if len(tasks_id): - cr.execute('select id,create_date,state,planned_hours from project_task where id in ('+','.join(map(str,tasks_id))+') order by create_date') + cr.execute('select id,create_date,state,planned_hours from project_task where id in %s order by create_date',(tuple(tasks_id),)) tasks = cr.fetchall() - cr.execute('select w.date,w.hours from project_task_work w left join project_task t on (t.id=w.task_id) where t.id in ('+','.join(map(str,tasks_id))+') and t.state in (\'open\',\'progress\') order by date') - + cr.execute('select w.date,w.hours from project_task_work w left join project_task t on (t.id=w.task_id) where t.id in %s and t.state in (%s,%s) order by date',(tuple(tasks_id),'open','progress',)) tasks2 = cr.fetchall() - cr.execute('select date_close,planned_hours from project_task where id in ('+','.join(map(str,tasks_id))+') and state in (\'cancelled\',\'done\') order by date_close') + cr.execute('select date_close,planned_hours from project_task where id in %s and state in (%s,%s) order by date_close' ,(tuple(tasks_id),'cancelled','done',)) tasks2 += cr.fetchall() tasks2.sort() else: diff --git a/addons/scrum/report/task_burndown.py b/addons/scrum/report/task_burndown.py index 977d8fe9e6c..b4c6481ce48 100644 --- a/addons/scrum/report/task_burndown.py +++ b/addons/scrum/report/task_burndown.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -42,9 +42,10 @@ class external_pdf(render): def burndown_chart(cr, uid, tasks_id, date_start, date_stop): latest = False - cr.execute('select id,date_start,state,planned_hours from project_task where id in ('+','.join(map(str,tasks_id))+') order by date_start') + + cr.execute('select id,date_start,state,planned_hours from project_task where id in %s order by date_start'(tuple(tasks_id),)) tasks = cr.fetchall() - cr.execute('select id,date_close,state,planned_hours*progress/100 from project_task where id in ('+','.join(map(str,tasks_id))+') and state in (%s,%s) order by date_close', ('progress','done')) + cr.execute('select id,date_close,state,planned_hours*progress/100 from project_task where id in %s and state in (%s,%s) order by date_close', (tuple(tasks_id),'progress','done',)) tasks2 = cr.fetchall() current_date = date_start total = 0 @@ -71,14 +72,14 @@ class report_tasks(report_int): io = StringIO.StringIO() if 'date_start' not in datas: - cr.execute('select min(date_start) from project_task where id in ('+','.join(map(str, ids))+')') + cr.execute('select min(date_start) from project_task where id in %s',(tuple(ids),)) dt = cr.fetchone()[0] if dt: datas['date_start'] = dt[:10] else: datas['date_start'] = time.strftime('%Y-%m-%d') if 'date_stop' not in datas: - cr.execute('select max(date_start),max(date_close) from project_task where id in ('+','.join(map(str, ids))+')') + cr.execute('select max(date_start),max(date_close) from project_task where id in %s',(tuple(ids),)) res = cr.fetchone() datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d') if res[1] and datas['date_stop']