Rifakat (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-opw-16778-rha into
lp:openobject-addons/6.0.
Requested reviews:
Raphael Collet (OpenERP) (rco-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-16778-rha/+merge/79385
Hello,
Improved functionality for search criteria of base_report_creator module.
Search criteria was not working and throwing errors. Improved sql query for
filters.
Kindly review it.
Regards,
Rifakat
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-16778-rha/+merge/79385
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-opw-16778-rha.
=== modified file 'base_report_creator/base_report_creator.py'
--- base_report_creator/base_report_creator.py 2011-01-17 08:00:48 +0000
+++ base_report_creator/base_report_creator.py 2011-10-14 10:23:24 +0000
@@ -200,21 +200,43 @@
i += 1
else:
fields['column_count'] = (False, 'Count')
- newargs = []
- newargs2 = []
+ where_str = ''
+ where_clause = ''
+ param_value = ''
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]))]
- ctx = context or {}
- ctx['getid'] = True
- sql_query = report.sql_query
- cr.execute(sql_query) # TODO: FILTER
- result = cr.fetchall()
- return map(lambda x: x[0], result)
+ from_clause, where_clause, where_clause_params = res.get_sql()
+ if where_clause:
+ if where_clause_params:
+ if isinstance(where_clause_params[0], str):
+ param_value = "'"+where_clause_params[0]+"'"
+ elif isinstance(where_clause_params[0], int):
+ param_value = tuple(where_clause_params)
+ if param_value:
+ if where_str:
+ where_str += ' and '+ (where_clause) % param_value
+ else:
+ where_str += (where_clause) % param_value
+ else:
+ where_str += (where_clause)
+ if report.filter_ids and where_str:
+ where_query = report.sql_query and report.sql_query.split('where') or ''
+ where = where_query[1].split('group by')
+ where_main = where[0] + ' and ' + where_str
+ query = where_query[0] + ' where ' + where_main + ' group by ' + where[1]
+ elif not report.filter_ids and where_str:
+ sql_query = report.sql_query and report.sql_query.split('group by')
+ where_str = where_str and (" where %s" % where_str)
+ query = sql_query[0] + where_str + ' group by ' + sql_query[1]
+ else:
+ query = report.sql_query and (report.sql_query + where_str) or ''
+ if query:
+ cr.execute(query)
+ result = cr.fetchall()
+ return map(lambda x: x[0], result)
+ else:
+ return []
report_result()
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp