Odoo 7 NameError:未定义名称'amount_to_text'

时间:2015-01-15 19:15:49

标签: python openerp-7

我正在使用openERP 7,我想在sale_order报告中打印发票金额,我发现了一些关于同一错误的问题,我按照说明操作但是没有工作(https://www.odoo.com/forum/help-1/question/conversion-of-amount-to-text-in-openerp-43765)我使用此答案和amount_to_text_es_MX进行测试。

首先我更改了sale_order.py文件,我导入了amount_to_text

import time

from openerp.report import report_sxw
from tools.translate import _
from tools import amount_to_text
from addons.l10n_mx_invoice_amount_to_text import amount_to_text_es_MX

class order(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(order, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'show_discount':self._show_discount,
            'amount_to_text_es_MX': amount_to_text_es_MX,
        })

在我的报告之后我写了

[[str(amount_to_text_es_MX(o.amount_total,"Pesos"))]]

日志显示以下错误

2015-01-15 18:19:00,914 22621 ERROR Gaby openerp.tools.safe_eval: Cannot eval 'str(amount_to_text_es_MX(o.amount_total,"Pesos"))'
Traceback (most recent call last):
  File "/opt/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 'amount_to_text_es_MX' is not defined

我希望有人可以帮助我 谢谢, 盖比

0 个答案:

没有答案