-
Notifications
You must be signed in to change notification settings - Fork 33
2. Include archives stored in Nextcloud as attachments to the email
Dolores Juliana Fernández edited this page Mar 28, 2019
·
3 revisions
If we want the attached files of a transaction to be sent in the emails written from that transaction, we will have to make a change in Frappe.
Frappe does not have hooks that allow us to invoke this functionality, for this reason after installing pibiapp it is necessary to make a change in the source code of Frappe.
In the file apps/frappe/frappe/core/doctype/file/file.py at the beginning of the function get_content include:
def get_content(self):
method = frappe.get_hooks('doc_events', app_name="pibiapp").get('File').get('get_content') if method: method = frappe.get_attr(method[0]) return method(self)
In the file apps/frappe/frappe/utils/file_manager.py at the beginning of the function get_file include:
def get_file(fname):
f = frappe.db.sql("""select file_name, name from `tabFile` where (name=%s or file_name=%s) and attached_to_doctype!='Communication' """, (fname, fname)) if f: file_name = f[0][0] name = f[0][1] if " NC" in file_name and "/f/" in file_name: file_doc = frappe.get_doc("File", {"file_name":file_name, "name":name}) method = frappe.get_hooks('doc_events', app_name="pibiapp").get('File').get('get_content') if method: method = frappe.get_attr(method[0]) content = method(file_doc) ncf = file_name.find(" NC") filename = file_name[0:ncf] return [filename, content]
Before testing this functionality you must compile, clean the cache and restart the bench.