콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
17148 화면

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


아바타
취소
베스트 답변

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

아바타
취소
작성자

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

관련 게시물 답글 화면 활동
7
4월 23
28142
0
4월 20
2716
1
7월 19
6025
3
8월 18
10371
3
12월 16
5519