首页 > 解决方案 > 如何在发票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>

推荐阅读