QWebException: "NoneType cannot be called" when evaluating

im running into a problem in the qweb report, I followed this tutorial http://blog.emiprotechnologies.com/create-qweb-report-odoo/ to create a qweb report, it handled the static data perfectly with my current module, but when I trying to create a parser class for dynamic data, I get this error "QWebException:" The object "NoneType" cannot be called "when evaluating" here this is my python class:

from openerp.osv import osv from openerp.report import report_sxw class etudiant_report_parser(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(etudiant_report_parser, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'hello_world': self.hello_world, }) self.context = context def hello_world(self): return "hello" class etudiant_object_report(osv.AbstractModel): _name = 'report.gestion_des_etudiants.etudiant_report' _inherit = 'report.abstract_report' _template = 'gestion_des_etudiants.etudiant_report' _wrapped_report_class = etudiant_report_parser 

And in my etudiant_report.xml XML file, I added this line:

 <span t-esc="hello_world()"/> 

But when I print the report, I get the error message:

 QWebException: "'NoneType' object is not callable" while evaluating 

Here is the arborescence of my module:

/ report / init .py <--- to load the etudiant_report.xml file that contains the parser class

/report/etudiant_report.py <---... contains the parser class

/views/report_etudiant.xml <--- xml file for report

init .py

OpenERP .py

etudiant_view.xml

etudiant_report.xml <--- report menu

etudiant.py

Another thing that I noticed when I went into the "report" folder, I did not find any .pyc file, for init .py and etudiant_report.py

+5
source share
1 answer

To call a custom method from a model, you can do the following:

Define a method in your model

 @api.multi def mymethod(self): return "mymethod" 

And then call the method from qweb. here is an example qweb code that calls a custom method from a model.

 <template id="th_custom_report"> <t t-call="report.html_container"> <t t-foreach="docs" t-as="o"> <t t-call="th_dynamic_report.th_report_id" t-lang="o.partner_id.lang"/> </t> </t> </template> <template id="th_report_id"> <t t-call="report.external_layout"> <t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" /> <span t-esc="o.mymethod()"/> </t> </t> <template> 

It will help you!

0
source

All Articles