[FIX] Base_report_creator corrected for boolean fields on sql query (ref:uco,jvo)
bzr revid: jvo@tinyerp.com-20090422150424-mhs31r7fhz7lrx5q
This commit is contained in:
parent
afc84be2e7
commit
7c82eeeda6
|
@ -229,7 +229,13 @@ class report_creator(osv.osv):
|
|||
filter_list.append(' ')
|
||||
filter_list.append(filter_id.condition)
|
||||
|
||||
ret_str = ",\n".join(from_list)
|
||||
if len(from_list) == 1 and filter_ids:
|
||||
from_list.append(' ')
|
||||
ret_str = "\n where \n".join(from_list)
|
||||
else:
|
||||
ret_str = ",\n".join(from_list)
|
||||
|
||||
|
||||
if where_list:
|
||||
ret_str+="\n where \n"+" and\n".join(where_list)
|
||||
ret_str = ret_str.strip()
|
||||
|
@ -261,23 +267,28 @@ class report_creator(osv.osv):
|
|||
fields.append('\t'+f.group_method+'('+t+'.'+f.field_id.name+')'+' as field'+str(i))
|
||||
i+=1
|
||||
models = self._path_get(cr, uid, obj.model_ids, obj.filter_ids)
|
||||
check=self._id_get(cr, uid, ids[0], context)
|
||||
check = self._id_get(cr, uid, ids[0], context)
|
||||
if check<>False:
|
||||
fields.insert(0,(check+' as id'))
|
||||
result[obj.id] = """select
|
||||
%s
|
||||
from
|
||||
%s
|
||||
""" % (',\n'.join(fields), models)
|
||||
if groupby:
|
||||
result[obj.id] += "group by\n\t"+', '.join(groupby)
|
||||
if where_plus:
|
||||
result[obj.id] += "\nhaving \n\t"+"\n\t and ".join(where_plus)
|
||||
if limit:
|
||||
result[obj.id] += " limit "+str(limit)
|
||||
if offset:
|
||||
result[obj.id] += " offset "+str(offset)
|
||||
|
||||
if models:
|
||||
result[obj.id] = """select
|
||||
%s
|
||||
from
|
||||
%s
|
||||
""" % (',\n'.join(fields), models)
|
||||
if groupby:
|
||||
result[obj.id] += "group by\n\t"+', '.join(groupby)
|
||||
if where_plus:
|
||||
result[obj.id] += "\nhaving \n\t"+"\n\t and ".join(where_plus)
|
||||
if limit:
|
||||
result[obj.id] += " limit "+str(limit)
|
||||
if offset:
|
||||
result[obj.id] += " offset "+str(offset)
|
||||
else:
|
||||
result[obj.id] = False
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Report Name',size=64, required=True),
|
||||
'type': fields.selection([('list','Rows And Columns Report'),], 'Report Type',required=True),#('sum','Summation Report')
|
||||
|
|
|
@ -122,20 +122,25 @@ def _set_filter_value(self, cr, uid, data, context):
|
|||
model_pool = pooler.get_pool(cr.dbname).get(model_name)
|
||||
table_name = model_pool._table
|
||||
model_name = model_pool._description
|
||||
|
||||
if field_type == 'boolean' and value_data == 1:
|
||||
value_data = 'true'
|
||||
else:
|
||||
value_data = 'false'
|
||||
|
||||
if field_type:
|
||||
if field_type == 'many2many' and value_data and len(value_data):
|
||||
fields_list = set_field_operator(self,table_name+"."+field_data['name'],field_data['ttype'],form_data['operator'],value_data[0][2])
|
||||
else:
|
||||
fields_list = set_field_operator(self,table_name+"."+field_data['name'],field_data['ttype'],form_data['operator'],value_data)
|
||||
|
||||
|
||||
if fields_list and value_data:
|
||||
create_dict = {
|
||||
'name':model_name + "/" +field_data['field_description'] +" "+ mapping_fields[form_data['operator']] + " " + str(fields_list[2]),
|
||||
'name':model_name + "/" +field_data['field_description'] +" "+ mapping_fields[form_data['operator']] + " " + str(fields_list[2]) + " ",
|
||||
'expression':' '.join(fields_list),
|
||||
'report_id':data['id'],
|
||||
'condition' : form_data['condition']
|
||||
}
|
||||
|
||||
pooler.get_pool(cr.dbname).get('base_report_creator.report.filter').create(cr,uid,create_dict)
|
||||
#end if field_type == 'many2many' and value_data and len(value_data):
|
||||
# pooler.get_pool(cr.dbname).get('custom.report.filter').create(cr,uid,form_data)
|
||||
|
|
Loading…
Reference in New Issue