HI All
I’d like to add custom python function to be computed on my report, but I stuck with common known error:
"'NoneType' object is not callable" while evaluating 'testme()'
I’ve checked this forum and other tutorials and I can’t see any mistake in my code, but for sure there is one. Could you be so kind and point what I am doing wrong?
Files structure:
/__init__.py
/__openerp__.py
/controllers/__init__.py
/models/__init__.py
/report/__init__.py
/report/reports.xml
/report/sample_report.xml
/report/sample_report_document.xml
/raport/sample_report_parser.py
/demo/demo.xml
File Content:
/__init__.py
from . import controllers
from . import models
import report
/__openerp__.py
{
'name': "bmbi_test",
'summary': """
Test""",
'description': """
Long description of module's purpose
""",
'author': "b",
'website': "",
'category': 'Uncategorized',
'version': '0.1',
'data': [
'views/views.xml',
'views/templates.xml',
'report/sample_report.xml',
'report/sample_report_document.xml',
'report/reports.xml',
],
'demo': [
'demo.xml',
],
}
report/__init__.py
import sample_report_parser
/report/reports.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<report
id="bmbi_sample"
model="account.invoice"
string="Test"
report_type="qweb-html"
name="bmbi_test.report_bmbi_sample"
file="bmbi_test.report_bmbi_sample"
attachment_use="False"
attachment="(object.state in ('open','paid')) and ('FV '+(object.number or '').replace('/','')+'.pdf')">
</report>
</data>
</odoo>
/report/sample_report.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_bmbi_sample" name="bmbi_test.report_bmbi_sample">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="bmbi_test.report_bmbi_sample_document" t-lang="o.partner_id.lang"/>
</t>
</t>
</template>
</data>
</odoo>
/report/sample_report_document.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_bmbi_sample_document" name="bmbi_test.report_bmbi_sample_document">
<div class="page">
<div class="row">
<div>
<t t-esc="testme()"/>
</div>
</div>
</div>
</template>
</data>
</odoo>
/raport/sample_report_parser.py
from openerp.osv import osv
from openerp.report import report_sxw
import time
class sample_raport_parser (report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(bmbi_invoice_report_parser, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'testme':self._testme
})
def _testme(self):
return "ABC"
class bmbi_sample_report_parser(osv.AbstractModel):
_name = 'report.bmbi_test.report_bmbi_sample'
_inherit = 'report.abstract_report'
_template = 'bmbi_test.report_bmbi_sample'
_wrapped_report_class = sample_raport_parser