0

When I save an invoice after adding new invoice lines with products under VAT, the total VAT amount is not automatically updated.

Is there a way to compute automatically the amount tax when the invoice is saved ?

Why it is not native behavior ?

Any help will be much appreciated

Cheers

1 Answers1

0
amount_untaxed = fields.Monetary(string='Untaxed Amount',
    store=True, readonly=True, compute='_compute_amount', track_visibility='always')
amount_tax = fields.Monetary(string='Tax',
    store=True, readonly=True, compute='_compute_amount')
amount_total = fields.Monetary(string='Total',
    store=True, readonly=True, compute='_compute_amount')

@api.one
@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id', 'date_invoice', 'type')
def _compute_amount(self):
    round_curr = self.currency_id.round
    self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line_ids)
    self.amount_tax = sum(round_curr(line.amount) for line in self.tax_line_ids)
    self.amount_total = self.amount_untaxed + self.amount_tax

you can see account.invoice default module. Always update record while create. In custom module In create method update the record as above.

Naglis
  • 2,583
  • 1
  • 19
  • 24
Urmila Bhuva
  • 161
  • 6