如何显示发票中的更新值?

问题描述 投票:0回答:1

我正在计算税额,即'amount_untaxed','amount_tax'和'amount_total'并更新它们,但在创建发票时'amount_tax'值消失了。

@api.depends('order_line.price_total')
def _amount_all(self):
    """
    Compute the total amounts of the SO.
    """
    lines = []
    count = 0
    for order in self:
        amount_untaxed = amount_tax = 0.0
        for line in order.order_line:
            for tax in line.tax_id:
                if tax.name == 'Ava_Tax':
                    count += 1
                    lines.append({
                        'number': count,
                        'amount': line.price_subtotal,
                        'taxCode': line.product_id.avalara_product_code,
                        'description': line.product_id.name,
                        'quantity': line.product_uom_qty
                    })
                    self.tax_document['lines'] = lines
                    value = self.get_tax_avalara()
                    amount_tax = value
                else:
                    amount_tax += line.price_tax

            amount_untaxed += line.price_subtotal
            order.update({
                'amount_untaxed': amount_untaxed,
                'amount_tax': amount_tax,
                'amount_total': amount_untaxed + amount_tax,
            })

有帮助吗?

odoo invoice tax
1个回答
0
投票

请输入以下代码

@api.depends('order_line.price_total')
def _amount_all(self):
    res = super(SaleOrder, self)._amount_all()
    """
    Compute the total amounts of the SO.
    """
    lines = []
    count = 0
    for order in self:
        amount_untaxed = amount_tax = 0.0
        for line in order.order_line:
            for tax in line.tax_id:
                if tax.name == 'Ava_Tax':
                    count += 1
                    lines.append({
                    'number': count,
                    'amount': line.price_subtotal,
                    'taxCode': line.product_id.avalara_product_code,
                    'description': line.product_id.name,
                    'quantity': line.product_uom_qty
                    })
                    self.tax_document['lines'] = lines
                    value = self.get_tax_avalara()
                    amount_tax = value
                else:
                    amount_tax += line.price_tax
            amount_untaxed += line.price_subtotal
            order.update({
            'amount_untaxed': amount_untaxed,
            'amount_tax': amount_tax,
            'amount_total': amount_untaxed + amount_tax,
            })
    return res

在运行函数之前调用超级函数。还请在清单依赖项中提及销售

© www.soinside.com 2019 - 2024. All rights reserved.