Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Odoo 7名称错误:名称“金额到文本”未定义_Python_Openerp 7 - Fatal编程技术网

Python Odoo 7名称错误:名称“金额到文本”未定义

Python Odoo 7名称错误:名称“金额到文本”未定义,python,openerp-7,Python,Openerp 7,我正在使用openERP 7,我想在销售订单报告中将发票金额打印为文本,我发现了一些关于相同错误的问题,我按照说明进行了操作,但不起作用。我使用此答案和金额到文本进行了测试 首先,我更改了sale\u order.py文件,将amount\u导入了\u文本 import time from openerp.report import report_sxw from tools.translate import _ from tools import amount_to_text from ad

我正在使用openERP 7,我想在销售订单报告中将发票金额打印为文本,我发现了一些关于相同错误的问题,我按照说明进行了操作,但不起作用。我使用此答案和金额到文本进行了测试

首先,我更改了sale\u order.py文件,将amount\u导入了\u文本

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,
        })
在我写报告之后

[[stramount_to_text_es_MXo.amount_total,比索]]

日志显示了以下错误

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
我希望有人能帮助我 谢谢
Gaby

也将金额导入到init文件中的文本中。重新启动并告诉我它是否工作我解决了问题:D。我在openerp/addons/sale_order.py中添加了导入代码,问题是安装添加了2个插件目录,我只将导入代码添加到一个目录,而没有添加到另一个目录。我还将文件amount\u改为\u text.py改为python2.7/dist-packages谢谢!!