This question has been flagged
1 Reply
1282 Views

Hi,


I'm creating an invoice via API, via some try-and-error I'm abel to create an invoice.

For each line item i'm adding the correct TAX rate:


'product_id'=>1,

'account_id'=>374, //7000 verkoen goederen

'move_id'=>30,

'tax_ids'=>array(1), //1= 21%

'price_unit'=>14.95,

'quantity'=>1,


But for some reason the tax totals aren't calclated on save of the invoice. Does somebody now how I can trigger a recalculation of the taxes on the created invoice please?


brg,






Avatar
Discard
Best Answer

Hey Steve,

I'm sure you might have solved this already. Anyhow, I'm posting the following as I also faced this issue on V16 and was able to fix the issue by calling the following functions - I'm hoping this might be helpful for others as well :)

  • _compute_totals (line item level)
  • _compute_balance (line item level)
  • _compute_tax_totals (invoice level)

Here is the exact lines that I used:

	​move_line.with_context(check_move_validity=False)._compute_totals()
​move_line.with_context(check_move_validity=False)._compute_balance()
move.with_context(check_move_validity=False)._compute_tax_totals()
Avatar
Discard