From a6cfc17f74f392410499b071cb27dcfac92c126d Mon Sep 17 00:00:00 2001 From: "atp (Open ERP)" Date: Wed, 17 Mar 2010 18:25:17 +0530 Subject: [PATCH 1/2] [IMP]: base_report_creator: code optimization and apply csv file bzr revid: atp@tinyerp.co.in-20100317125517-2j196axg121h0k2x --- .../base_report_creator.py | 380 +++++++++++------- .../base_report_creator_view.xml | 3 +- .../security/ir.model.access.csv | 9 +- .../wizard/report_menu_create.py | 10 +- 4 files changed, 238 insertions(+), 164 deletions(-) diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py index 95c2e8a76e6..00f23faba99 100644 --- a/addons/base_report_creator/base_report_creator.py +++ b/addons/base_report_creator/base_report_creator.py @@ -19,10 +19,7 @@ # ############################################################################## -import string -import time -import tools -from osv import fields,osv,orm +from osv import fields, osv from tools.translate import _ class report_creator(osv.osv): @@ -36,51 +33,74 @@ class report_creator(osv.osv): # Should request only used fields # def export_data(self, cr, uid, ids, fields_to_export, context=None): + if not context: context = {} data_l = self.read(cr, uid, ids, ['sql_query'], context) - final_datas =[] + final_datas = [] #start Loop for i in data_l: datas = [] - for key,value in i.items(): + for key, value in i.items(): if key not in fields_to_export: continue - if isinstance(value,tuple): + if isinstance(value, tuple): datas.append(str(value[1])) else: datas.append(str(value)) final_datas += [datas] #End Loop - return {'datas':final_datas} + return {'datas': final_datas} def fields_get(self, cr, user, fields=None, context=None): + """ + Get Fields. + @param cr: the current row, from the database cursor, + @param user: the current user’s ID for security checks, + @param Fields: List of field of customer reports form. + @return: Dictionary of Fields + """ + if not context: + context = {} + + data = context and context.get('report_id', False) or False if (not context) or 'report_id' not in context: return super(report_creator, self).fields_get(cr, user, fields, context) - report = self.browse(cr, user, context['report_id']) - models = {} + if data: + report = self.browse(cr, user, data) + models = {} #Start Loop - for model in report.model_ids: - models[model.model] = self.pool.get(model.model).fields_get(cr, user, context=context) - #End Loop - fields = {} - i = 0 - for f in report.field_ids: - if f.field_id.model: - fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] - i+=1 - else: - fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'} - - return fields + for model in report.model_ids: + models[model.model] = self.pool.get(model.model).fields_get(cr, user, context=context) + #End Loop + fields = {} + i = 0 + for f in report.field_ids: + if f.field_id.model: + fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] + i += 1 + else: + fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'} + + return fields # # Should Call self.fields_get ! # def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + """ + Overrides orm field_view_get. + @param cr: the current row, from the database cursor, + @param user: the current user’s ID for security checks, + @return: Dictionary of Fields, arch and toolbar. + """ + if not context: + context = {} + + data = context and context.get('report_id', False) or False if (not context) or 'report_id' not in context: return super(report_creator, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) - report = self.browse(cr, user, context['report_id']) + report = self.browse(cr, user, data) models = {} for model in report.model_ids: models[model.model] = self.pool.get(model.model).fields_get(cr, user, context=context) @@ -89,33 +109,33 @@ class report_creator(osv.osv): for f in report.field_ids: if f.field_id.model: fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] - i+=1 + i += 1 else: fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'} arch = '\n' - if view_type=='graph': - arch +='' % (report.name, report.view_graph_type,report.view_graph_orientation) + if view_type == 'graph': + arch += '' % (report.name, report.view_graph_type, report.view_graph_orientation) for val in ('x','y'): i = 0 for f in report.field_ids: - if f.graph_mode==val: + if f.graph_mode == val: if f.field_id.model: arch += '' % ('field'+str(i),) - i+=1 + i += 1 else: arch += '' % ('column_count',) - elif view_type=='calendar': - required_types = ['date_start','date_delay','color'] - set_dict = {'view_type':view_type,'string':report.name} + elif view_type == 'calendar': + required_types = ['date_start', 'date_delay', 'color'] + set_dict = {'view_type':view_type, 'string':report.name} temp_list = [] - i=0 + i = 0 for f in report.field_ids: if f.calendar_mode and f.calendar_mode in required_types: if f.field_id.model: field_cal = 'field'+str(i) - i+=1 + i += 1 else: field_cal = 'column_count' set_dict[f.calendar_mode] = field_cal @@ -123,20 +143,20 @@ class report_creator(osv.osv): else: if f.field_id.model: - temp_list.append('''''' % {'name':'field'+str(i)}) - i+=1 + temp_list.append('''''' % {'name': 'field' + str(i)}) + i += 1 else: temp_list.append('''''' % {'name':'column_count'}) - arch += '''<%(view_type)s string="%(string)s" date_start="%(date_start)s" ''' %set_dict - if set_dict.get('date_delay',False): - arch +=''' date_delay="%(date_delay)s" '''%set_dict + arch += '''<% (view_type)s string = "%(string)s" date_start = "%(date_start)s" ''' % set_dict + if set_dict.get('date_delay', False): + arch += ''' date_delay = "%(date_delay)s" ''' % set_dict - if set_dict.get('date_stop',False): - arch +=''' date_stop="%(date_stop)s" '''%set_dict + if set_dict.get('date_stop', False): + arch += ''' date_stop="%(date_stop)s" '''%set_dict - if set_dict.get('color',False): - arch +=''' color="%(color)s"'''%set_dict + if set_dict.get('color', False): + arch += ''' color="%(color)s"'''%set_dict arch += '''>''' arch += ''.join(temp_list) else: @@ -144,8 +164,8 @@ class report_creator(osv.osv): i = 0 for f in report.field_ids: if f.field_id.model: - arch += '' % ('field'+str(i),) - i+=1 + arch += '' % ('field' + str(i),) + i += 1 else: arch += '' % ('column_count',) arch += '' % (view_type,) @@ -158,33 +178,53 @@ class report_creator(osv.osv): 'action': [], 'relate': [] } + return result def read(self, cr, user, ids, fields = None, context = None, load = '_classic_read'): + """ + overrides orm Read method.Read List of fields for report creator. + @param cr: the current row, from the database cursor, + @param user: the current user’s ID for security checks, + @param ids: List of report creator's id. + @param fields: List of fields. + @return: List of Dictionary of form [{‘name_of_the_field’: value, ...}, ...] + """ + data = context and context.get('report_id', False) or False if (not context) or 'report_id' not in context: return super(report_creator, self).read(cr, user, ids, fields, context, load) ctx = context or {} wp = '' - if self.model_set_id: - wp = [self._id_get(cr, user, context['report_id'], context)+(' in (%s)' % (','.join(map(lambda x: "'"+str(x)+"'",ids))))] - report = self._sql_query_get(cr, user, [context['report_id']], 'sql_query', None, ctx, where_plus = wp) - sql_query = report[context['report_id']] - cr.execute(sql_query) - res = cr.dictfetchall() - fields_get = self.fields_get(cr,user,None,context) - for r in res: - for k in r: - r[k] = r[k] or False - field_dict = fields_get.get(k) - field_type = field_dict and field_dict.get('type',False) or False - if field_type and field_type == 'many2one': - if r[k]==False: - continue - related_name = self.pool.get(field_dict.get('relation')).name_get(cr,user,[r[k]],context)[0] - r[k] = related_name - return res + if data: + if self.model_set_id: + wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))] + report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp) + sql_query = report[data] + cr.execute(sql_query) + res = cr.dictfetchall() + fields_get = self.fields_get(cr, user, None, context) + for r in res: + for k in r: + r[k] = r[k] or False + field_dict = fields_get.get(k) + field_type = field_dict and field_dict.get('type', False) or False + if field_type and field_type == 'many2one': + if r[k] == False: + continue + related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0] + r[k] = related_name + + return res def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): + """ + overrides orm search method. + @param cr: the current row, from the database cursor, + @param user: the current user’s ID for security checks, + @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. + @return: List of id + """ + context_id = context and context.get('report_id', False) or False if (not context) or 'report_id' not in context: @@ -196,16 +236,16 @@ class report_creator(osv.osv): for f in report.field_ids: if f.field_id.model: fields['field'+str(i)] = (f.field_id.model, f.field_id.name) - i+=1 + i += 1 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] + 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 {} @@ -216,8 +256,12 @@ class report_creator(osv.osv): result = cr.fetchall() return map(lambda x: x[0], result) - def _path_get(self,cr, uid, models, filter_ids=[]): - + def _path_get(self, cr, uid, models, filter_ids=[]): + """ + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param models: List of object. + """ self.model_set_id = False model_dict = {} from_list = [] @@ -225,7 +269,7 @@ class report_creator(osv.osv): filter_list = [] for model in models: model_dict[model.model] = self.pool.get(model.model)._table - + model_list = model_dict.keys() reference_model_dict = {} for model in model_dict: @@ -233,7 +277,7 @@ class report_creator(osv.osv): rest_list = model_dict.keys() rest_list.remove(model) model_pool = self.pool.get(model) - fields_get = model_pool.fields_get(cr,uid) + fields_get = model_pool.fields_get(cr, uid) model_columns = {} def _get_inherit_fields(obj): @@ -242,24 +286,24 @@ class report_creator(osv.osv): model_columns.update(pool_model._columns) #Adding the columns of its _inherits for record in pool_model._inherits.keys(): - _get_inherit_fields(record) + _get_inherit_fields(record) _get_inherit_fields(model) - fields_filter = dict(filter(lambda x:x[1].get('relation',False) + fields_filter = dict(filter(lambda x:x[1].get('relation', False) and x[1].get('relation') in rest_list - and x[1].get('type')=='many2one' - and not (isinstance(model_columns[x[0]],fields.function) or isinstance(model_columns[x[0]],fields.related)), fields_get.items())) + and x[1].get('type') == 'many2one' + and not (isinstance(model_columns[x[0]], fields.function) or isinstance(model_columns[x[0]], fields.related)), fields_get.items())) if fields_filter: model in model_list and model_list.remove(model) - model_count = reference_model_dict.get(model,False) + model_count = reference_model_dict.get(model, False) if model_count: reference_model_dict[model] = model_count +1 else: reference_model_dict[model] = 1 - for k,v in fields_filter.items(): + for k, v in fields_filter.items(): v.get('relation') in model_list and model_list.remove(v.get('relation')) - relation_count = reference_model_dict.get(v.get('relation'),False) + relation_count = reference_model_dict.get(v.get('relation'), False) if relation_count: reference_model_dict[v.get('relation')] = relation_count+1 else: @@ -271,9 +315,9 @@ class report_creator(osv.osv): if reference_model_dict: self.model_set_id = model_dict.get(reference_model_dict.keys()[reference_model_dict.values().index(min(reference_model_dict.values()))]) if model_list and not len(model_dict.keys()) == 1: - raise osv.except_osv(_('No Related Models!!'),_('These is/are model(s) (%s) in selection which is/are not related to any other model') % ','.join(model_list)) + raise osv.except_osv(_('No Related Models!!'), _('These is/are model(s) (%s) in selection which is/are not related to any other model') % ','.join(model_list)) - if filter_ids and where_list<>[]: + if filter_ids and where_list <> []: filter_list.append(' and ') filter_list.append(' ') @@ -288,25 +332,32 @@ class report_creator(osv.osv): else: ret_str = ",\n".join(from_list) - if where_list: where_list = list(set(where_list)) - ret_str+="\n where \n"+" and\n".join(where_list) + ret_str += "\n where \n"+" and\n".join(where_list) ret_str = ret_str.strip() if filter_list: - ret_str +="\n".join(filter_list) + ret_str += "\n".join(filter_list) if ret_str.endswith('and'): ret_str = ret_str[0:len(ret_str)-3] if ret_str.endswith('or'): ret_str = ret_str[0:len(ret_str)-2] ret_str = ret_str.strip() - return ret_str % {'uid' : uid} + + return ret_str % {'uid': uid} def _id_get(self, cr, uid, id, context): + """ + Get Model id + """ # return 'min(sale_order_line.id)' return self.model_set_id and 'min('+self.model_set_id+'.id)' def _sql_query_get(self, cr, uid, ids, prop, unknow_none, context, where_plus=[], limit=None, offset=None): + """ + Get sql query which return on sql_query field. + @return: Dictionary of sql query. + """ result = {} for obj in self.browse(cr, uid, ids): fields = [] @@ -315,7 +366,7 @@ class report_creator(osv.osv): for f in obj.field_ids: # Allowing to use count(*) if not f.field_id.model and f.group_method == 'count': - fields.insert(0,('count(*) as column_count')) + fields.insert(0, ('count(*) as column_count')) continue t = self.pool.get(f.field_id.model_id.model)._table if f.group_method == 'group': @@ -323,11 +374,11 @@ class report_creator(osv.osv): else: fields.append('\t'+f.group_method+'('+t+'.'+f.field_id.name+')'+' as field'+str(i)) groupby.append(t+'.'+f.field_id.name) - i+=1 + i += 1 models = self._path_get(cr, uid, obj.model_ids, obj.filter_ids) check = self._id_get(cr, uid, ids[0], context) if check<>False: - fields.insert(0,(check+' as id')) + fields.insert(0, (check + ' as id')) if models: result[obj.id] = """select @@ -348,49 +399,58 @@ class report_creator(osv.osv): 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') - 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the report without removing it."), - 'view_type1': fields.selection([('form','Form'), - ('tree','Tree'), - ('graph','Graph'), - ('calendar','Calendar')], 'First View', required=True), - 'view_type2': fields.selection([('','/'), - ('form','Form'), - ('tree','Tree'), - ('graph','Graph'), - ('calendar','Calendar')], 'Second View'), - 'view_type3': fields.selection([('','/'), - ('form','Form'), - ('tree','Tree'), - ('graph','Graph'), - ('calendar','Calendar')], 'Third View'), - 'view_graph_type': fields.selection([('pie','Pie Chart'), - ('bar','Bar Chart')], 'Graph Type', required=True), - 'view_graph_orientation': fields.selection([('horz','Horizontal'), - ('vert','Vertical')], 'Graph Orientation', required=True), - 'model_ids': fields.many2many('ir.model', 'base_report_creator_report_model_rel', 'report_id','model_id', 'Reported Objects'), - 'field_ids': fields.one2many('base_report_creator.report.fields', 'report_id', 'Fields to Display'), - 'filter_ids': fields.one2many('base_report_creator.report.filter', 'report_id', 'Filters'), + 'name': fields.char('Report Name', size=64, required=True), + 'type': fields.selection([('list', 'Rows And Columns Report'), ], 'Report Type', required=True), #('sum','Summation Report') + 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the report without removing it."), + 'view_type1': fields.selection([('form', 'Form'), + ('tree', 'Tree'), + ('graph', 'Graph'), + ('calendar', 'Calendar')], 'First View', required=True), + 'view_type2': fields.selection([('', '/'), + ('form', 'Form'), + ('tree', 'Tree'), + ('graph', 'Graph'), + ('calendar', 'Calendar')], 'Second View'), + 'view_type3': fields.selection([('', '/'), + ('form', 'Form'), + ('tree', 'Tree'), + ('graph', 'Graph'), + ('calendar', 'Calendar')], 'Third View'), + 'view_graph_type': fields.selection([('pie', 'Pie Chart'), + ('bar', 'Bar Chart')], 'Graph Type', required=True), + 'view_graph_orientation': fields.selection([('horz', 'Horizontal'), + ('vert', 'Vertical')], 'Graph Orientation', required=True), + 'model_ids': fields.many2many('ir.model', 'base_report_creator_report_model_rel', 'report_id', 'model_id', 'Reported Objects'), + 'field_ids': fields.one2many('base_report_creator.report.fields', 'report_id', 'Fields to Display'), + 'filter_ids': fields.one2many('base_report_creator.report.filter', 'report_id', 'Filters'), 'state': fields.selection([ - ('draft','Draft'), - ('valid','Valid')], - 'State', required=True, + ('draft', 'Draft'), + ('valid', 'Valid')], + 'State', required=True, help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed custom report. \ - \n* The \'Valid\' state is used when user validates the custom report.'), - 'sql_query': fields.function(_sql_query_get, method=True, type="text", string='SQL Query', store=True), - 'group_ids': fields.many2many('res.groups', 'base_report_creator_group_rel','report_id','group_id','Authorized Groups'), + \n* The \'Valid\' state is used when user validates the custom report.'), + 'sql_query': fields.function(_sql_query_get, method=True, type="text", string='SQL Query', store=True), + 'group_ids': fields.many2many('res.groups', 'base_report_creator_group_rel', 'report_id', 'group_id', 'Authorized Groups'), } _defaults = { - 'type': lambda *args: 'list', - 'state': lambda *args: 'draft', - 'active': lambda *args: True, - 'view_type1': lambda *args: 'tree', - 'view_type2': lambda *args: 'graph', - 'view_graph_type': lambda *args: 'bar', - 'view_graph_orientation': lambda *args: 'horz', + 'type': lambda *args: 'list', + 'state': lambda *args: 'draft', + 'active': lambda *args: True, + 'view_type1': lambda *args: 'tree', + 'view_type2': lambda *args: 'graph', + 'view_graph_type': lambda *args: 'bar', + 'view_graph_orientation': lambda *args: 'horz', } def _function_field(self, cr, uid, ids): + """ + constraints function which specify that + not display field which are not stored in Database. + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of Report creator's id. + @return: True if display field which are stored in database. + or false if display field which are not store in dtabase. + """ this_objs = self.browse(cr, uid, ids) for obj in this_objs: for fld in obj.field_ids: @@ -398,13 +458,23 @@ class report_creator(osv.osv): if not fld.field_id.model and fld.group_method == 'count': continue model_column = self.pool.get(fld.field_id.model)._columns[fld.field_id.name] - if (isinstance(model_column,fields.function) or isinstance(model_column,fields.related)) and not model_column.store: + if (isinstance(model_column, fields.function) or isinstance(model_column, fields.related)) and not model_column.store: return False return True def _aggregation_error(self, cr, uid, ids): - aggregate_columns = ('integer','float') - apply_functions = ('sum','min','max','avg','count') + """ + constraints function which specify that + aggregate function to the non calculated field.. + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of Report creator's id. + @return: True if model colume type is in integer or float. + or false model colume type is not in integer or float. + """ + + aggregate_columns = ('integer', 'float') + apply_functions = ('sum', 'min', 'max', 'avg', 'count') this_objs = self.browse(cr, uid, ids) for obj in this_objs: for fld in obj.field_ids: @@ -421,7 +491,7 @@ class report_creator(osv.osv): required_types = [] this_objs = self.browse(cr, uid, ids) for obj in this_objs: - if obj.view_type1=='calendar' or obj.view_type2=='calendar' or obj.view_type3=='calendar': + if obj.view_type1 == 'calendar' or obj.view_type2 == 'calendar' or obj.view_type3 == 'calendar': for fld in obj.field_ids: # Allowing to use count(*) if not fld.field_id.model and fld.group_method == 'count': @@ -438,12 +508,13 @@ class report_creator(osv.osv): return True _constraints = [ - (_function_field, 'You can not display field which are not stored in Database.', ['field_ids']), - (_aggregation_error, 'You can apply aggregate function to the non calculated field.', ['field_ids']), - (_calander_view_error, "You must have to give calendar view's color,start date and delay.", ['field_ids']), + (_function_field, 'You can not display field which are not stored in Database.', ['field_ids']), + (_aggregation_error, 'You can apply aggregate function to the non calculated field.', ['field_ids']), + (_calander_view_error, "You must have to give calendar view's color,start date and delay.", ['field_ids']), ] report_creator() + class report_creator_field(osv.osv): """ Report Creator Field @@ -453,28 +524,29 @@ class report_creator_field(osv.osv): _rec_name = 'field_id' _order = "sequence,id" _columns = { - 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of fields."), - 'field_id': fields.many2one('ir.model.fields', 'Field'), - 'report_id': fields.many2one('base_report_creator.report','Report', on_delete='cascade'), - 'group_method': fields.selection([('group','Grouped'), - ('sum','Sum'), - ('min','Minimum'), - ('count','Count'), - ('max','Maximum'), - ('avg','Average')], 'Grouping Method', required=True), - 'graph_mode': fields.selection([('','/'), - ('x','X Axis'), - ('y','Y Axis')], 'Graph Mode'), - 'calendar_mode': fields.selection([('','/'), - ('date_start','Starting Date'), - ('date_end','Ending Date'),('date_delay','Delay'),('date_stop','End Date'),('color','Unique Colors')], 'Calendar Mode'), + 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of fields."), + 'field_id': fields.many2one('ir.model.fields', 'Field'), + 'report_id': fields.many2one('base_report_creator.report', 'Report', on_delete='cascade'), + 'group_method': fields.selection([('group', 'Grouped'), + ('sum', 'Sum'), + ('min', 'Minimum'), + ('count', 'Count'), + ('max', 'Maximum'), + ('avg', 'Average')], 'Grouping Method', required=True), + 'graph_mode': fields.selection([('', '/'), + ('x', 'X Axis'), + ('y', 'Y Axis')], 'Graph Mode'), + 'calendar_mode': fields.selection([('', '/'), + ('date_start', 'Starting Date'), + ('date_end', 'Ending Date'), ('date_delay', 'Delay'), ('date_stop', 'End Date'), ('color', 'Unique Colors')], 'Calendar Mode'), } _defaults = { - 'group_method': lambda *args: 'group', - 'graph_mode': lambda *args: '', + 'group_method': lambda *args: 'group', + 'graph_mode': lambda *args: '', } report_creator_field() + class report_creator_filter(osv.osv): """ Report Creator Filter @@ -482,14 +554,14 @@ class report_creator_filter(osv.osv): _name = "base_report_creator.report.filter" _description = "Report Filters" _columns = { - 'name': fields.char('Filter Name',size=64, required=True), - 'expression': fields.text('Value', required=True, help='Provide an expression for the field based on which you want to filter the records.\n e.g. res_partner.id=3'), - 'report_id': fields.many2one('base_report_creator.report', 'Report', on_delete='cascade'), - 'condition' : fields.selection([('and','AND'), - ('or','OR')], 'Condition') + 'name': fields.char('Filter Name', size=64, required=True), + 'expression': fields.text('Value', required=True, help='Provide an expression for the field based on which you want to filter the records.\n e.g. res_partner.id=3'), + 'report_id': fields.many2one('base_report_creator.report', 'Report', on_delete='cascade'), + 'condition': fields.selection([('and', 'AND'), + ('or', 'OR')], 'Condition') } _defaults = { - 'condition': lambda *args: 'and', + 'condition': lambda *args: 'and', } report_creator_filter() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_report_creator/base_report_creator_view.xml b/addons/base_report_creator/base_report_creator_view.xml index a69aed42048..ac3052a7769 100644 --- a/addons/base_report_creator/base_report_creator_view.xml +++ b/addons/base_report_creator/base_report_creator_view.xml @@ -41,7 +41,8 @@ - +