feat: use email template for membership acknowledgement

This commit is contained in:
Shivam Mishra 2020-08-05 17:33:33 +05:30
parent b4d3666e69
commit 6b68eaad1e
2 changed files with 14 additions and 18 deletions

View File

@ -99,11 +99,14 @@ class Membership(Document):
if self.invoice and settings.send_invoice: if self.invoice and settings.send_invoice:
attachments.append(frappe.attach_print("Sales Invoice", self.invoice, print_format=settings.inv_print_format)) 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 = { email_args = {
"recipients": [email], "recipients": [email],
"message": settings.message, "message": frappe.render_template(email_template.get("response"), context),
"subject": _('Here is your invoice'), "subject": frappe.render_template(email_template.get("subject"), context),
"attachments": [frappe.attach_print("Sales Invoice", invoice.name, print_format=settings.inv_print_format)], "attachments": attachments,
"reference_doctype": self.doctype, "reference_doctype": self.doctype,
"reference_name": self.name "reference_name": self.name
} }

View File

@ -19,8 +19,7 @@
"send_invoice", "send_invoice",
"membership_print_format", "membership_print_format",
"inv_print_format", "inv_print_format",
"section_break_15", "email_template"
"message"
], ],
"fields": [ "fields": [
{ {
@ -96,7 +95,7 @@
"default": "0", "default": "0",
"fieldname": "send_email", "fieldname": "send_email",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Send Acknowledge Email" "label": "Send Membership Acknowledgement"
}, },
{ {
"depends_on": "eval: doc.send_invoice", "depends_on": "eval: doc.send_invoice",
@ -111,26 +110,20 @@
"fieldname": "membership_print_format", "fieldname": "membership_print_format",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Membership Print Format", "label": "Membership Print Format",
"mandatory_depends_on": "eval:doc.send_email",
"options": "Print Format" "options": "Print Format"
}, },
{ {
"depends_on": "eval:doc.send_email", "depends_on": "eval:doc.send_email",
"fieldname": "section_break_15", "fieldname": "email_template",
"fieldtype": "Section Break", "fieldtype": "Link",
"hide_border": 1 "label": "Email Template",
}, "mandatory_depends_on": "eval:doc.send_email",
{ "options": "Email Template"
"depends_on": "eval:doc.send_email",
"fieldname": "message",
"fieldtype": "Text Editor",
"label": "Message"
} }
], ],
"index_web_pages_for_search": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2020-07-31 14:30:15.701767", "modified": "2020-08-05 17:26:37.287395",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Non Profit", "module": "Non Profit",
"name": "Membership Settings", "name": "Membership Settings",