[IMP]:MRP module sql queries to parameterized query

bzr revid: nch@tinyerp.com-20091124131045-cl53el8bke3o1py2
This commit is contained in:
nch@tinyerp.com 2009-11-24 18:40:45 +05:30
parent c214c029d4
commit c13ca999d8
2 changed files with 15 additions and 16 deletions

View File

@ -215,9 +215,9 @@ class mrp_bom(osv.osv):
]
def _check_recursion(self, cr, uid, ids):
level = 500
level = 100
while len(ids):
cr.execute('select distinct bom_id from mrp_bom where id in ('+','.join(map(str, ids))+')')
cr.execute('select distinct bom_id from mrp_bom where id =ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False

View File

@ -98,14 +98,13 @@ class report_custom(report_int):
def create(self, cr, uid, ids, datas, context={}):
assert len(ids), 'You should provide some ids!'
colors = choice_colors(len(ids))
ids_str = ','.join(map(str, ids))
cr.execute(
"SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\
"FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\
"WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\
"AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\
"AND mrp_production.state NOT IN ('cancel','done') "\
"AND mrp_workcenter.id IN (%s)" % ids_str)
"AND mrp_workcenter.id =ANY(%s)",(ids,))
res = cr.dictfetchone()
if not res['stop']:
res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S')
@ -136,8 +135,8 @@ class report_custom(report_int):
# select workcenters
cr.execute(
"SELECT id, name FROM mrp_workcenter " \
"WHERE id in (%s) "\
"ORDER BY mrp_workcenter.id" % ids_str)
"WHERE id=ANY(%s)" \
"ORDER BY mrp_workcenter.id" ,(ids,))
workcenters = cr.dictfetchall()
data = []