Odoo Help


Pass filters to pentaho report

on 8/19/13, 8:53 AM 1,687 views
    I have a table calldata1 and i want to show its contents in report print. i created pentaho report by adding  calldata1 as datasource and uplodaded this report to open erp. Then i created a wizard table  calldata_print_report_wiz . i created a pop up window which displays datestart, date end ,caller from this table as filters. (similar to Reporting/Point of sale/Sale details).
    i print data by passing filters to report my corrected code is given below

    from osv import osv,fields
    class calldata1(osv.osv):
      _name = 'calldata1'
      _columns = {
                  'Call_start': fields.datetime('Call start'),
                  'Call_duration':fields.datetime('Call duration'),

    import logging
    from openerp.osv import fields, osv
    import time

    class calldata_print_report_wiz(osv.osv_memory):
        _name = "calldata.print.report.wiz"
        def _sel_func(self, cr, uid,context=None):
           obj = self.pool.get('calldata1')
           ids = obj.search(cr, uid, [])
           res = obj.read(cr, uid, ids, ['id','Caller'], context)
           res =[(r['id'],r['Caller']) for r in res]
          return res

        _columns = {
            'date_start': fields.date('Date Start', required=True),
            'date_end': fields.date('Date End', required=True),
        _defaults = {
            'date_start': lambda *a: time.strftime('%Y-%m-%d'),
            'date_end': lambda *a: time.strftime('%Y-%m-%d'),

 34     def print_report(self, cr, uid, ids, context=None):
 36       _logger = logging.getLogger(__name__)
 37       datas = {}
 38       if context is None:
 39             context = {}
 40       res = self.read(cr, uid, ids, ['date_start', 'date_end', 'caller_id'], context=context)
 41       caller_id  = ''
 42       date_start = res[0]['date_start'] + ' 00:00:00'
 43       date_end = res[0]['date_end'] +  ' 23:59:59'
 44       if res[0]['caller_id']:
 45         caller_id = res[0]['caller_id']
 46       calldata_obj = self.pool.get('calldata')
 47       if caller_id:
 48        cr.execute("select caller from calldata where id=%s",(caller_id,))
 49        caller = cr.fetchone()
 50        ids  = calldata_obj.search(cr, uid, [('call_start','>=',date_start),('call_start','<=',date_end),('caller','=',caller[0])])
 51       else:
 52        ids  = calldata_obj.search(cr, uid, [('call_start','>=',date_start),('call_start','<=',date_end)])
 53       calldats = calldata_obj.read(cr, uid, ids, ['caller','call_start'], context)
 54       datas['ids'] = ids
 55       datas['form']= calldats
 56       datas['model']= 'calldata'
 57       if (ids == []):
 58          datas = {}
 59       return {
 60              'type': 'ir.actions.report.xml',
 61              'report_name':'calldata',
 62              'datas':datas,
 64             }


any one der? please help :(

on 8/20/13, 2:24 AM

Did you solved it yet? Looking for the same solution.

on 10/23/13, 8:18 AM

@evon Yes i solved it . i will update question with correct code.Plz inform if it helped you

on 10/24/13, 1:25 AM

@evon i posted correct code . what is the issue ?

on 10/24/13, 7:11 AM

line 50, i have same type of work but it gives the error "TypeError: 'list' object is not callable" :(

on 10/24/13, 7:53 AM

@evon will u post u r code as different question and give link. i will check

on 10/24/13, 7:55 AM

Thanks but it works now.

on 10/24/13, 8:01 AM

@evon then vote 4 me :)

on 10/24/13, 8:03 AM

:) done

on 10/24/13, 8:08 AM

and how do you print the value of a field in wizard to the report?

on 10/24/13, 9:33 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 8/19/13, 8:53 AM
Seen: 1687 times
Last updated: 3/16/15, 8:10 AM