Hooks between Applications Problem

we are just starting evaluating frappe/erpnext and are quite impressed about the concept. Missing features to another solution with a lot of “OOO” are for our opinion totally ok for the target market. Anyway, we just see if we can replicate functionality from that into an additional app.
For this reason we have to hook into things like sales invoice Following the thread in the forum, i used hooks.py
in our app with the following code snippet:

doc_events = {“Sales Invoice”:{“validate”:“esaas.edms.doctype.document_types.document_types.doSomething”}

to just call a small function within the new app on validate event:

class DocumentTypes(Document):
def doSomething():
counter = 1
print “hook reached”

The following error is received:
AttributeError: ‘module’ object has no attribute 'doSomething’

If anyone could give a short advice, it would be very great.

Best Regards



Just guessing your problems

please makse sure the fucntion for hooks has no indent so its actually not part of the class
Yours :
class DocumentTypes(Document):
"tab"def doSomething():
“tab”"tab"counter = 1
“tab”"tab"print "hook reached

should be:

class DocumentTypes(Document):
def doSomething():
"tab"counter = 1
"tab"print "hook reached

hope this helps


Thanks very much for the fast answer. It works that way.
Can I also use a function within the class?
Best Regards again

No, that wouldn’t be possible. You can make a class and write a wrapper function that initializes and calls the required function and add the wrapper function to hooks.py