Auto Create Sales Invoice Submited where Submit Delivery Note

Hi,
is there any experience about make auto create sales invoice submited where submit delivery note?

my code

from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice
def create_sales_invoice(doc,event):
new_doc_si.save()
new_doc_si.submit()

this function i create on Dellivery Note on submite, result is create sales invoice submited but status not save like this

is there missing steps?

thanks.

Sorry, this complete code