Я попытался создать собственный синтаксический анализатор для моего отчета qweb на основе некоторых руководств в Интернете:
ig_account_object_printout_report_parser.py
import time
from openerp.osv import osv
from openerp.report import report_sxw
class ig_account_object_printout_report_parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(ig_account_object_printout_report_parser, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'hello_world': self._hello_world,
})
def _hello_world(self, field):
return "Hello World!"
class ig_account_object_report(osv.AbstractModel):
_name = 'ig_account.ig_account_object_printout_report_template'
_inherit = 'report.abstract_report'
_template = 'ig_account.ig_account_object_printout_report_template'
_wrapped_report_class = ig_account_object_printout_report_parser
ig_account_object_printout_report.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="ig_account_object_printout"
model="ig.account.object"
string="Print Account Object"
report_type="qweb-pdf"
name="ig_account.ig_account_object_printout_report_template"
attachment_use="False"
file="ig_account.ig_account_object_printout_report_template"
/>
</data>
</openerp>
ig_account_object_printout_report_template.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="ig_account_object_printout_report_template">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<span t-esc="hello_world()"/>
</div>
</t>
</t>
</template>
</data>
</openerp>
Мне нужен собственный парсер, потому что без него я не смогу вызвать функцию python для обработки некоторых данных.
Но когда я попытался запустить отчет, он возвращает:
QWebException: "'NoneType' object is not callable" while evaluating
'hello_world()'
Я включил ig_account_object_printout_report_parser.py
в __init__.py
Я что-то упускаю?