odoo-8 - 如何在发票odoo 8中显示税收百分比而不是税收名称
解决方案
name_get返回 中记录的文本表示self
。
默认情况下,这是该display_name
字段的值。
该方法在account.tax中重新定义以使用描述(代码)字段或名称字段。在下面的示例中,我们将覆盖相同的方法来显示税额百分比。
class AccountTax(models.Model):
_inherit = 'account.tax'
@api.multi
def name_get(self):
res = []
for record in self:
percentage = int(record.amount * 100)
name = str(percentage) + "%"
res.append((record.id, name))
return res
编辑:
要在发票报告中使用相同的表示形式(使用名称字段作为税名),只需调用该name_get
函数即可获取显示名称。
示例:继承发票报告以使用显示名称而不是税名
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//tbody[hasclass('invoice_tbody')]/tr/td[5]/span" position="attributes">
<attribute name="t-esc">', '.join(map(lambda x: x.name_get()[0][1], l.invoice_line_tax_id))</attribute>
</xpath>
</template>
推荐阅读
- opengl - 在 OpenGL 4.6 中没有对我有用的 alpha 混合
- java - Spring Boot 将时间戳转换为 UTC,但是当从数据库中获取时转换为服务器时间
- c - JACK 音频声音在播放时改变
- python - python渲染字符串windows路径
- node.js - GraphQL 模式查询无法识别解析器函数中传递的输入参数
- java - 将散列函数从 php 重写为 java - 其他结果
- python - 在 python 中实例化元类
- amazon-web-services - 将数据直接从 Filebeats 推送到 AWS ES 托管服务
- python - 模块的相对导入触发错误
- encryption - 非对称加密(公钥加密)我需要澄清