This question has been flagged
3 Replies
5087 Views

Hi there i need help here grin emoticon

i need to get values from function get_timetable but when i want to print the report it says
QWebException: "'NoneType' object is not callable" while evaluating
'get_timetable(o)'

fci_time_table_report.py


    import time
    from openerp import  osv
    from openerp.report import report_sxw
    
    class timetable_info(report_sxw.rml2sxw):
        def __init__(self, cr, uid, name, context=None):
            super(timetable_info, self).__init__(cr, uid, name, context=context)
            self.localcontext.update({
                'time': time,
                'get_timetable':self._get_timetable,
            })
    
        def _get_timetable(self, timetable_id):
            timetable_detail=[]
            
            self.cr.execute(" select t.start_time,t.end_time,s.name,week_day,r.name as"
                            " teacher from fci_time_table_line t, fci_subject_subject s, resource_resource r, "
                            "hr_employee hr where t.subject_id= s.id and t.teacher_id= hr.id  and "
                            "hr.resource_id = r.id  and table_id = %d group by start_time,end_time,s.name,week_day,r.name"
                            " order by start_time"%(timetable_id.id))
            res = self.cr.dictfetchall()
            self.cr.execute("select start_time,end_time from fci_time_table_line where table_id=%d group by start_time,end_time  order by start_time"%(timetable_id.id))
            time_data = self.cr.dictfetchall()
            for time_detail in time_data:
                for data in res:
                    if time_detail['start_time']==data['start_time'] and time_detail['end_time']==data['end_time']:
                        if (data['name']=='Recess'):
                            time_detail[data['week_day']] = data['name']
                        else:
                            time_detail[data['week_day']] = data['name']+ '\n(' +data['teacher']+')'
                timetable_detail.append(time_detail)
            return timetable_detail
    class report_time_table(osv.AbstractModel):
        _name = 'FCI_ERP.timetable_report_document'
        _inherit = 'report.abstract_report'
        _template = 'FCI_ERP.timetable_report_document'
        _wrapped_report_class = timetable_info

and here it is my report view in XML

   
     <table class="gridtable center">
    <tr t-foreach="get_timetable(o)" t-as="a">
    
    <td>
    <span t-esc=" a['start_time'] - a['end_time']"/>
    </td>
    
    <td>
    <span t-esc="a['saturday'] "/>
    </td>
    <td>
    <span t-esc="o['sunday']"/>
    </td>
    </tr>
    </table>

 

Avatar
Discard
Author

Edited any help ?

your depends in __openerp__.py?

Author

ok thanks ,, i have another question,,i'm new and i don't know what i do write or not in xml ? to get the values by this function,,thanks in advance

Author

@Emipro Technologies Pvt. Ltd. it still same error :( QWebException: "'NoneType' object is not callable" while evaluating 'get_timetable(o)'

Best Answer

In __openerp__.py, try this

'depends': ['hr','report']

Avatar
Discard
Author Best Answer

Still same problem :(

QWebException: "'NoneType' object is not callable" while evaluating
'get_timetable(o)'

 

Avatar
Discard

1) you enable debug and verify execution timetable_info(). Executed or no? 2) report call definition in xml? 3) v7 or v8?

Author

No i don't enable debug mode i edit the code and upgrade if the module still have same error i reinstall and so... yea i follow that guide http://blog.emiprotechnologies.com/create-qweb-report-odoo/... odoo-V8

so did you find the solution ??

Best Answer

Hi,

You just need to change one thing as like below.

class timetable_info(report_sxw.rml_parse):
        def __init__(self, cr, uid, name, context=None):
            super(timetable_info, self).__init__(cr, uid, name, context=context)
            self.localcontext.update({
                'time': time,
                'get_timetable':self._get_timetable,
            })

Here you just need to change inherited class name. I hope it will work.

Avatar
Discard