Autoname hook on Sales Invoice not working

I tried to make custom autoname for sales invoice but ‘autoname’ hook not fired, I used ‘before_insert’ instead. it got fired but the name still use default naming_series

Whats wrong?

Can you share your code?


def si_before_insert(self, method): = self.my_order_no

the problem is frappe has made autoname using default series before executing before_insert hook

But autoname hook is not working,it works for other doctypes…can you give a clue?


You can also use the autoname function in the file. This should do the trick.

def autoname(self): = self.my_order_no

changing core file shall break future updates…i want to do it via custom app…do you know why autoname hook not fired? doesn’t has autoname method, that’s why autoname hook not working

Custom App -

doc_events = {
	"Sales Invoice": {
		"autoname": "custom_app.hooked_methods.set_si_autoname"

Created a file inside the custom_app -

import frappe

def set_si_autoname(doc, method): = doc.po_no # or in your case doc.my_order_no

Seems to be working just fine.