Hi !
I have a custom function in a report parser :
import time
from openerp.report import report_sxw
class account_invoice(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_invoice, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
})
def cheque_no(self, voucher):
try:
cheque_no = voucher.cheque_number
if not cheque_no:
# no value in field
return ''
# value in field
return cheque_no
except AttributeError:
# field not defined
return False
report_sxw.report_sxw(
'report.custom.account.invoice',
'account.invoice',
'account_payment_method/report/account_print_invoice.rml',
parser=account_invoice
)
Now, I want to use it in my RML report :
<blockTable colWidths="150.0,70.0,70.0,70.0,170.0" style="Table_Payment_ids_header">
<tr>
<td>
<para style="terp_tblheader_Details"><b>Payment method [[ o.voucher_ids==[] and removeParentNode('blockTable') ]]</b></para>
</td>
<td>
<para style="terp_tblheader_Details_Centre"><b>Date </b></para>
</td>
<td>
<para style="terp_tblheader_Details_Right"><b>Amount </b></para>
</td>
<td>
<para style="terp_tblheader_Details_Right"><b>Cheque No. [[ cheque_no(o.voucher_ids[0])==False and removeParentNode('td') ]] </b></para>
</td>
<td>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<section>
<para style="terp_default_2">[[ repeatIn(o.voucher_ids,'v') ]]</para>
<blockTable colWidths="150.0,70.0,70.0,70.0,170.0" style="Table_Payment_ids_content">
<tr>
<td>
<para style="terp_default_8">[[ v.journal_id.name ]]</para>
</td>
<td>
<para style="terp_default_Centre_8">[[ v.move_id.date ]]</para>
</td>
<td>
<para style="terp_default_Right_8">[[ formatLang(v.amount, digits=get_digits(dp='Account'), currency_obj=o.currency_id) ]]</para>
</td>
<td>
<para style="terp_default_Right_8">[[ cheque_no(v) or cheque_no(v)==False and removeParentNode('td') ]]</para>
</td>
<td>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
</section>
But the server returns me this error :
2014-11-05 09:02:34,429 4023 ERROR other openerp.tools.safe_eval: Cannot eval " cheque_no(o.voucher_ids[0])==False and removeParentNode('td') "
Traceback (most recent call last):
File "/home/openerp/server/openerp/tools/safe_eval.py", line 285, in safe_eval
return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
File "", line 1, in <module>
NameError: name 'cheque_no' is not defined
Can someone help me solve this ?