Skip to Content
Menu
This question has been flagged
1 Reply
17104 Views

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


Avatar
Discard
Best Answer

See how to do it here:

https://www.odoo.com/fr_FR/forum/help-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244

Avatar
Discard
Author

thanks Axel, I read it earlier. I think my problem was related with indents. After code cleansing everything works fine - I'm quite new to odoo and python. Thanks for your post and help

Related Posts Replies Views Activity
7
Apr 23
28046
0
Apr 20
2648
1
Jul 19
5994
3
Aug 18
10313
3
Dec 16
5482