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.