我已经用 webkit 报告中的 amount_to_text 函数尝试了我所知道的一切,但我只是无处可去。我查看了支票书写模块并尽可能多地复制它,但仍然没有结果。我使用的是 webkit 而不是 rml,我不确定这是否会在 v7 中有所不同,因为相同的代码在 6.1 中可以正常工作。任何帮助将不胜感激
这是 .py 文件中的代码:
import time
from report import report_sxw
from osv import osv
from openerp.osv import osv,fields
from openerp.tools.translate import _
from openerp.tools.amount_to_text_en import amount_to_text
class tax_receipt(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(tax_receipt, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'cr':cr,
'uid': uid,
'amount_to_text': amount_to_text,
})
report_sxw.report_sxw('report.tax.receipt',
'account.bank.statement.line',
'addons/account_financial_report_webkit/report/webkit_html_bank_statement.mako',
parser=tax_receipt)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
mako 文件的摘录如下所示:
<table width="95%" cellpadding="5px" cellpadding="5px">
<tbody>
<tr style="text-align:left;border-bottom:1px solid;">
<td width="10%">The sum of </td>
<td width="80%" style="text-align:left;border-bottom:1px solid;">**${ amount_to_text(inv.amount) }**</td>
</tr>
</tbody>
</table>
当我尝试生成报告时,我得到:
Traceback (most recent call last):
File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\report_webkit\webkit_report.py", line 266, in create_single_pdf
File "mako\template.pyc", line 302, in render
File "mako\runtime.pyc", line 660, in _render
File "mako\runtime.pyc", line 692, in _render_context
File "mako\runtime.pyc", line 718, in _exec_template
File "memory:0x4a2d6d0", line 78, in render_body
<td width="80%" style="text-align:left;border-bottom:1px solid;">${ amount_to_text(inv.amount) }</td>
TypeError: 'Undefined' object is not callable
谢谢你。