我如何在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_words
xml
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_words
xml
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)"/>
答案 0 :(得分:1)
在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
或仅通过google进行安装。