如何在odoo-10中获取发票中的文字金额。我在account_invoice.py中添加了以下代码
@api.multi
def amount_to_text(self, amount, currency):
convert_amount_in_words = amount_to_text_en.amount_to_text(amount, lang='en', currency='')
convert_amount_in_words = convert_amount_in_words.replace(' and Zero Cent', ' Only ')
return convert_amount_in_wordsxml
t-esc="o.amount_to_text(o.amount_total, o.currency_id)" /> 我得到了以下错误
如何在odoo-10中获取发票中的文字金额。我在account_invoice.py中添加了以下代码
@api.multi
def amount_to_text(self, amount, currency):
convert_amount_in_words = amount_to_text_en.amount_to_text(amount, lang='en', currency='')
convert_amount_in_words = convert_amount_in_words.replace(' and Zero Cent', ' Only ')
return convert_amount_in_wordsxml
t-esc="o.amount_to_text(o.amount_total, o.currency_id)" /> 我得到了以下错误
Odoo Server Error
Traceback (most recent call last):
File "/opt/bahmni-erp/addons/report/controllers/main.py", line 96, in report_download
response = self.report_routes(reportname, docids=docids, converter='pdf')
File "/usr/lib/python2.7/site-packages/odoo-10.0-py2.7.egg/odoo/http.py", line 507, in response_wrap
response = f(*args, **kw)
File "/opt/bahmni-erp/addons/report/controllers/main.py", line 45, in report_routes
pdf = report_obj.with_context(context).get_pdf(docids, reportname, data=data)
File "/opt/bahmni-erp/addons/report/models/report.py", line 181, in get_pdf
html = self.with_context(context).get_html(docids, report_name, data=data)
File "/opt/bahmni-erp/addons/report/models/report.py", line 147, in get_html
return self.render(report.report_name, docargs)
File "/opt/bahmni-erp/addons/report/models/report.py", line 123, in render
return view_obj.render_template(template, values)
File "/usr/lib/python2.7/site-packages/odoo-10.0-py2.7.egg/odoo/addons/base/ir/ir_ui_view.py", line 1052, in render_template
return self.browse(self.get_view_id(template)).render(values, engine)
File "/opt/bahmni-erp/addons/web_editor/models/ir_ui_view.py", line 26, in render
return super(IrUiView, self).render(values=values, engine=engine)
File "/usr/lib/python2.7/site-packages/odoo-10.0-py2.7.egg/odoo/addons/base/ir/ir_ui_view.py", line 1072, in render
return self.env[engine].render(self.id, qcontext)
File "/usr/lib/python2.7/site-packages/odoo-10.0-py2.7.egg/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 53, in render
return super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
File "/usr/lib/python2.7/site-packages/odoo-10.0-py2.7.egg/odoo/addons/base/ir/ir_qweb/qweb.py", line 251, in render
self.compile(template, options)(self, body.append, values or {})
File "/usr/lib/python2.7/site-packages/odoo-10.0-py2.7.egg/odoo/addons/base/ir/ir_qweb/qweb.py", line 320, in _compiled_fn
raise e
QWebException: 'account.invoice' object has no attribute 'amount_to_text'
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/odoo-10.0-py2.7.egg/odoo/addons/base/ir/ir_qweb/qweb.py", line 318, in _compiled_fn
return compiled(self, append, values, options, log)
File "<template>", line 1, in template_account_account_invoice_report_duplicate_440
File "<template>", line 3, in body_call_content_439
AttributeError: 'account.invoice' object has no attribute 'amount_to_text'
Error to render compiling AST
AttributeError: 'account.invoice' object has no attribute 'amount_to_text'
Template: account.account_invoice_report_duplicate
Path: /templates/t/t/div/div[4]/div/table/tr[3]/td[2]/span[2]
Node: <span t-esc="o.amount_to_text(o.amount_total, o.currency_id)"/> 发布于 2019-06-21 13:02:48
在Odoo 11中,我通常这样做:
<t t-esc="doc.currency_id.amount_to_text(doc.amount_total)"/>这里的currency_id字段应该在你的记录中。amount_total这里是引用中的总金额字段。在Odoo 10中尝试一下,但我不确定它是否能在Odoo 10中工作。
在Odoo10中,我通常这样做:
<t t-esc="o.amount_total" t-esc-options='{"widget": "num2words","case":"capital"}'/>在这里,我们必须安装num2words模块才能正常工作。你可以通过pip install num2words或者谷歌来安装它。
https://stackoverflow.com/questions/56596947
复制相似问题