Odoo Help

0

Odoo Qweb Reports problems

By
Mostafa Mohamed Abdel Monaem
on 2/28/15, 9:30 AM 2,280 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>

 

Edited any help ?

Mostafa Mohamed Abdel Monaem
on 3/3/15, 3:32 PM

your depends in __openerp__.py?

Zbik
on 3/3/15, 3:36 PM

hr

Mostafa Mohamed Abdel Monaem
on 3/3/15, 4:40 PM

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

Mostafa Mohamed Abdel Monaem
on 3/3/15, 4:45 PM

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

Mostafa Mohamed Abdel Monaem
on 3/4/15, 2:47 AM
1
Zbik
On 3/3/15, 4:43 PM

In __openerp__.py, try this

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

0

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.

0

Still same problem :(

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

 

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

Zbik
on 3/3/15, 5:01 PM

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

Mostafa Mohamed Abdel Monaem
on 3/3/15, 5:06 PM

so did you find the solution ??

Alaa Ahmed
on 6/5/17, 6:37 PM

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.

Register

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

2 follower(s)

Stats

Asked: 2/28/15, 9:30 AM
Seen: 2280 times
Last updated: 4/8/15, 3:13 PM