Does a method exist that returns a doctype when passed a document name? Something with this sort of flavor?
Which would return “Purchase Invoice” as a string?
I’m not entirely sure where to look if it’s not in model or meta or db or __init__ where it might be.
Nope, there is no such method
But you can check below method
We are using this method for global search, it will return the list of records from multiple doctypes, where the search keyword is present
This makes lots of sense. I don’t think there’s a perfect way to get the doctype from a record’s name anyway, except to make the best guess and then try it. I’ll post the code here when I figure it out.
: I’ll leave this without a solution until I can post the code.
Good challenge Tyler -
For code learning clues such as you seek, there’s this here to be mined for gems
Dozens of handy well documented methods for the picking - just a few that I recognize
So after kicking this around with the team, we decided to also pull doctype along with any time we needed a name. Not that a function like this wouldn’t be useful, it’s just not as good as doing it the right way the first time.
@clarkej __init__.py is only surpassed in its utility and mystery by erpnext/hooks.py.