How to add tax at invoice level using ModelStorage

Dear tryton team.
I know this may be an easy action but I’m facing issues I’ll describe:

  1. Goal : I want to add a tax to invoice at invoice level (not line) using flask tryton.

  2. I’m trying to do it like:
    invoice_data = {‘party’: 52, ‘currency’: 12, ‘account’: 2, ‘company’: 1, ‘taxes’: [(‘add’, [1])]}
    just before the Invoice.create(invoice_data)

  3. I know taxes is related to account_invoice_tax model, so I need to create that instance and then add the id to my invoice? But that instance needs an invoice.id… so… I’m a littler lost

  4. Based on tryton client I know fields base, amount, are mandatory to create tax at invoice_level, but I don’t know how to add those properly.
    Thanks in advance.

1 Like

Why? taxes are managed on line level and automatically computed when the invoices is created. So it will be easier to set the tax for the line.

If you want to create a non computed record you should manually add all the flags and set the manual flag to True to avoid the system recomputing this line.

Ok, I think I’ll change my approach and try to find a better way, I was looking for include “discount” into the invoice.

Thanks @pokoli for your time.

Then you just need to set the propoer unit price on the line.
Tryton will take care of computing the correct taxes (if you also set them on the line) and everything else.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.