Hi everyone,
I am trying to call a method from hooks.py as like below.
In hooks.py(calling on save)
doc_events = {
"Quotation": {
"on_update": "app_name.hooks_call.quotation.update_quantity"
}
}
In hooks_call
quotation.py
from __future__ import unicode_literals
import frappe
from frappe.utils import flt, cstr, cint
from frappe import msgprint, _
@frappe.whitelist(allow_guest=True)
def update_quantity(self):
msgprint("update_quantity")
The message is not getting printed after clicking on save button.
Am I missing anything in the hooks.py?
Hello.
Your function must receive the doc and method params. Also make sure that hooks_call have an __init__.py
file:
def update_quantity(doc, method):
msgprint("update_quantity")
@froldan
after passing method, still that message is not displaying
@frappe.whitelist(allow_guest=True)
def update_quantity(self,method):
msgprint("update_quantity")
__init__.py
file is exist in hooks_call folder
Any other changes needs to be done
The console shows an error when you click on the save button? Can you check that?
@froldan
There are no errors in the browser console on click of save button.
rmehta
#6
You must clear cache after changing hooks
I ran these commands and restarted bench but my message is not getting printed.
bench --site [sitename] clear-website-cache
bench --site all clear-website-cache