Status of the Sales Invoice remains "Unpaid" . It's not changing as "Paid" as I given

While submitting a document, I wrote a python code such that a new document is created/auto inserted in Sales Invoice (using new_doc()) an in the same function, I wrote static values for the newly created sales Invoice Document, thus assigned the “Status” of Sales Invoice as “Paid”. I get the result as new document created while submitting the other document. Static fields are inserted as given in code. But the status of the Sales Invoice remains “Unpaid” . It’s not changing as “Paid” as I given. Any help please…

hello, maybe you can use before_save, before_submit or validate events because those fire before document is saved so you can change doc properties and they get saved