feat: use email template for membership acknowledgement
diff --git a/erpnext/non_profit/doctype/membership/membership.py b/erpnext/non_profit/doctype/membership/membership.py
index fc89396..f058004 100644
--- a/erpnext/non_profit/doctype/membership/membership.py
+++ b/erpnext/non_profit/doctype/membership/membership.py
@@ -99,11 +99,14 @@
if self.invoice and settings.send_invoice:
attachments.append(frappe.attach_print("Sales Invoice", self.invoice, print_format=settings.inv_print_format))
+ email_template = frappe.get_doc("Email Template", settings.email_template)
+ context = { "doc": self, "member": member}
+
email_args = {
"recipients": [email],
- "message": settings.message,
- "subject": _('Here is your invoice'),
- "attachments": [frappe.attach_print("Sales Invoice", invoice.name, print_format=settings.inv_print_format)],
+ "message": frappe.render_template(email_template.get("response"), context),
+ "subject": frappe.render_template(email_template.get("subject"), context),
+ "attachments": attachments,
"reference_doctype": self.doctype,
"reference_name": self.name
}
diff --git a/erpnext/non_profit/doctype/membership_settings/membership_settings.json b/erpnext/non_profit/doctype/membership_settings/membership_settings.json
index 2452a76..5b6bab5 100644
--- a/erpnext/non_profit/doctype/membership_settings/membership_settings.json
+++ b/erpnext/non_profit/doctype/membership_settings/membership_settings.json
@@ -19,8 +19,7 @@
"send_invoice",
"membership_print_format",
"inv_print_format",
- "section_break_15",
- "message"
+ "email_template"
],
"fields": [
{
@@ -96,7 +95,7 @@
"default": "0",
"fieldname": "send_email",
"fieldtype": "Check",
- "label": "Send Acknowledge Email"
+ "label": "Send Membership Acknowledgement"
},
{
"depends_on": "eval: doc.send_invoice",
@@ -111,26 +110,20 @@
"fieldname": "membership_print_format",
"fieldtype": "Link",
"label": "Membership Print Format",
- "mandatory_depends_on": "eval:doc.send_email",
"options": "Print Format"
},
{
"depends_on": "eval:doc.send_email",
- "fieldname": "section_break_15",
- "fieldtype": "Section Break",
- "hide_border": 1
- },
- {
- "depends_on": "eval:doc.send_email",
- "fieldname": "message",
- "fieldtype": "Text Editor",
- "label": "Message"
+ "fieldname": "email_template",
+ "fieldtype": "Link",
+ "label": "Email Template",
+ "mandatory_depends_on": "eval:doc.send_email",
+ "options": "Email Template"
}
],
- "index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2020-07-31 14:30:15.701767",
+ "modified": "2020-08-05 17:26:37.287395",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Membership Settings",