[IMP] Implmented multi level model where and filter support for the cutom reports Support Search also

bzr revid: jam@tinyerp.com-20111213104650-1n83dz95po3ps0ex
This commit is contained in:
Jigar Amin - OpenERP
2011-12-13 16:16:50 +05:30
parent 2be64b26b7
commit 808c5472c2
@@ -201,18 +201,15 @@ class report_result(osv.osv):
else:
fields['column_count'] = (False, 'Count')
newargs = []
newargs2 = []
for a in args:
if fields[a[0]][0]:
res = self.pool.get(fields[a[0]][0])._where_calc(cr, user, [[fields[a[0]][1], a[1], a[2]]], active_test = False, context = context)
newargs += res[0]
newargs2 += res[1]
else:
newargs += [("count(*) " + a[1] +" " + str(a[2]))]
model = self.pool.get(fields[a[0]][0])
newargs.append(str(model._table+"."+fields[a[0]][1] + " " +a[1] + " '" + a[2])+"'")
ctx = context or {}
ctx['getid'] = True
sql_query = report.sql_query
cr.execute(sql_query) # TODO: FILTER
report_pool = self.pool.get('base_report_creator.report')
reports = report_pool._sql_query_get(cr, user, [context_id], 'sql_query', None, ctx, where_plus=newargs, limit=limit, offset=offset)
cr.execute(reports[context_id])
result = cr.fetchall()
return map(lambda x: x[0], result)