Here is my function code:
@api.depends_context('lang')
@api.depends('order_line.taxes_id', 'order_line.price_subtotal', 'amount_untaxed', 'tax_amount', 'discount_amount')
def _compute_tax_totals(self):
for order in self:
order_lines = order.order_line.filtered(lambda x: not x.display_type)
# Step 1: Get base tax totals (Odoo default logic)
base_totals = self.env['account.tax']._prepare_tax_totals(
[line._convert_to_tax_base_line_dict() for line in order_lines],
order.currency_id or order.company_id.currency_id,
)
# Step 2: Override tax + discount logic
computed_tax = base_totals.get('amount_tax', 0.0)
tax_adjustment = order.tax_amount - computed_tax
tax_totals = base_totals['amount_total'] + tax_adjustment - order.discount_amount
# Step 3: Set modified tax_totals (overwrite the whole dict!)
order.tax_totals = {
**base_totals,
'amount_tax': order.tax_amount,
'amount_total': tax_totals,
'formatted_amount_total': order.currency_id.format(tax_totals),
}
I tried to update total amount on the purchase order, and for that I found tax_totlas field. I have found that it's not a field but a @property, so I can't update value like this. Please let me know what's wrong with my code and how can I acheive it. Thanks