I am trying to figure out the best approach to add a custom whitelist method to the sales invoice doctype which will get called on before ‘Before Submit’.
Should I add my custom whitelist method to /erpnext/accounts/doctype/sales_invoice/pos.py ?
Or
Should I be creating a custom app that holds this method?
My understanding is that you should avoid modifying the core .py files. How should I approach this?
The user is going to click submit. My custom method will get invoked which will post to an external URL. That URL will return a response. My custom method will analyze the response and either raise an error or allow the submit to continue.
if you are consuming the other url you can put it on server script , and it will works .
if you are trying to make a api method , create a new python file inside frappe ,
to call it use /api/method/frappe.file_name.function_name
also you can put the function inside the hooks.py file on the after submit section
it’s just python code . but erpnext may block it when you import the module requests .
If so ,try the second method . create the python file inside frappe and create your function .
Then ,inside the hooks.py file at the doc_events dict put it like this :
Yes, erpnext does block the import of requests. Therefore, doing it the second way means modifying core code of erpnext (for example, hooks.py). Is this ok to do for my case? Or is there a way to accomplish this without having to modify core erpnext files?
the only way is to find a ways to make server script accept your code .
As I said it’s okay , I got a lot of live server for clients and I always change the code .