【问题标题】:how to display tax percentage instead of tax name in invoice odoo 8如何在发票odoo 8中显示税收百分比而不是税收名称
【发布时间】:2021-10-08 10:49:44
【问题描述】:

我试图在会计>客户发票中显示税收百分比而不是他们的名字

我想从 会计 > 配置 > 税收 > 税收中获得百分比 我不知道如何实现这一点

【问题讨论】:

  • name_get 函数被重新定义为使用描述(代码)字段或名称字段。您可以覆盖它以使用另一个字段(例如计算百分比字段)或税名和百分比的组合。
  • 感谢@Kenly 的回复,我还在学习 odoo,还有很多我不明白的地方,所以如果你能用例子解释更多,将不胜感激

标签: odoo-8


【解决方案1】:

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 字段作为税名),只需调用 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>

【讨论】:

  • 我很抱歉@Kenly 打扰你,代码工作得很好,但是当我尝试打印发票时,我有税的名称而不是你能帮忙的百分比,谢谢
  • 没问题。发票报告使用税务名称(名称字段),您需要更改发票报告单据模板以使用显示名称。检查我的编辑
猜你喜欢
  • 1970-01-01
  • 2018-08-03
  • 1970-01-01
  • 1970-01-01
  • 2019-06-20
  • 2013-08-24
  • 1970-01-01
  • 1970-01-01
  • 2022-08-14
相关资源
最近更新 更多