Monkey Patch to add method in SalesInvoice
Hello, I need to add a custom method in SalesInvoice DocType.
I’ve tried with no success to add a monkey patch in hooks.py of my custom app as follow:
#hooks.py
from erpnext.accounts.doctype.sales_invoice.sales_invoice import SalesInvoice
def my_method(self):
return 'Foo'
SalesInvoice.my_method = my_method
Any ideas?
Thanks!
JoEz
2
what you need exactly to do?
Due frappe.db.sql doesn’t work in custom print format I need to add custom methods to SalesInvoice so I can call it in print format.
felix
4
Did you try some of the other solutions before trying a monkey patch? They may (or may not) work for your scenario.