Как отобразить обновленные значения в счете? - PullRequest
0 голосов
/ 01 октября 2019

Я рассчитываю налоговые значения, например, «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,
            })

Любая помощь?

1 Ответ

0 голосов
/ 01 октября 2019

Пожалуйста, напишите следующий код

@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

Вызовите суперфункцию перед запуском вашей функции. Также, пожалуйста, укажите продажу в явных зависимостях

...