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:
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
}

View File

@ -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",