In my custom model I tried to create a function that will create an invoice. However when I tried to Post the invoice using this code
invoice = self.env['account.move'].create(vals)
invoice.action_post()
The record was actual created and it was Posted but the amount due is 0. All other computations in the invoice are correct. What seems to be the problem here? Thanks in advance
Post the rest of your code, the contents of vals, and the types of each of the accounts you are using, there could be many things and readers can not guess from the information you have shared.
Thanks for pointing out. This is the code snippet base on the query above.
The
actually created a record and it is Posted automatically by
.However the amount due is 0. I checked the other values and it seems the amount residual is also 0. Other values such as Total amount and subtotals are correct. I tried to manually reset the record to draft and post it again. It works, but I should be able to do this via code.