feat(RFQ): make email message fully configurable (#36353)
feat: make RFQ message fully configurable
This commit is contained in:
parent
b86747c9d4
commit
21080afd92
@ -244,19 +244,21 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.fields_dict['supplier'].df.onchange = () => {
|
dialog.fields_dict["supplier"].df.onchange = () => {
|
||||||
var supplier = dialog.get_value('supplier');
|
frm.call("get_supplier_email_preview", {
|
||||||
frm.call('get_supplier_email_preview', {supplier: supplier}).then(result => {
|
supplier: dialog.get_value("supplier"),
|
||||||
|
}).then(({ message }) => {
|
||||||
dialog.fields_dict.email_preview.$wrapper.empty();
|
dialog.fields_dict.email_preview.$wrapper.empty();
|
||||||
dialog.fields_dict.email_preview.$wrapper.append(result.message);
|
dialog.fields_dict.email_preview.$wrapper.append(
|
||||||
|
message.message
|
||||||
|
);
|
||||||
|
dialog.set_value("subject", message.subject);
|
||||||
});
|
});
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
dialog.fields_dict.note.$wrapper.append(`<p class="small text-muted">This is a preview of the email to be sent. A PDF of the document will
|
dialog.fields_dict.note.$wrapper.append(`<p class="small text-muted">This is a preview of the email to be sent. A PDF of the document will
|
||||||
automatically be attached with the email.</p>`);
|
automatically be attached with the email.</p>`);
|
||||||
|
|
||||||
dialog.set_value("subject", frm.doc.subject);
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -20,11 +20,10 @@
|
|||||||
"items_section",
|
"items_section",
|
||||||
"items",
|
"items",
|
||||||
"supplier_response_section",
|
"supplier_response_section",
|
||||||
"salutation",
|
|
||||||
"subject",
|
|
||||||
"col_break_email_1",
|
|
||||||
"email_template",
|
"email_template",
|
||||||
"preview",
|
"preview",
|
||||||
|
"col_break_email_1",
|
||||||
|
"html_llwp",
|
||||||
"sec_break_email_2",
|
"sec_break_email_2",
|
||||||
"message_for_supplier",
|
"message_for_supplier",
|
||||||
"terms_section_break",
|
"terms_section_break",
|
||||||
@ -236,23 +235,6 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fetch_from": "email_template.subject",
|
|
||||||
"fetch_if_empty": 1,
|
|
||||||
"fieldname": "subject",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Subject",
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Select a greeting for the receiver. E.g. Mr., Ms., etc.",
|
|
||||||
"fieldname": "salutation",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Salutation",
|
|
||||||
"no_copy": 1,
|
|
||||||
"options": "Salutation",
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "col_break_email_1",
|
"fieldname": "col_break_email_1",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
@ -285,13 +267,19 @@
|
|||||||
"fieldname": "named_place",
|
"fieldname": "named_place",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Named Place"
|
"label": "Named Place"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "html_llwp",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"options": "<p>In your <b>Email Template</b>, you can use the following special variables:\n</p>\n<ul>\n <li>\n <code>{{ update_password_link }}</code>: A link where your supplier can set a new password to log into your portal.\n </li>\n <li>\n <code>{{ portal_link }}</code>: A link to this RFQ in your supplier portal.\n </li>\n <li>\n <code>{{ supplier_name }}</code>: The company name of your supplier.\n </li>\n <li>\n <code>{{ contact.salutation }} {{ contact.last_name }}</code>: The contact person of your supplier.\n </li><li>\n <code>{{ user_fullname }}</code>: Your full name.\n </li>\n </ul>\n<p></p>\n<p>Apart from these, you can access all values in this RFQ, like <code>{{ message_for_supplier }}</code> or <code>{{ terms }}</code>.</p>",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-shopping-cart",
|
"icon": "fa fa-shopping-cart",
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-01-31 23:22:06.684694",
|
"modified": "2023-07-27 14:01:14.534594",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Request for Quotation",
|
"name": "Request for Quotation",
|
||||||
|
|||||||
@ -179,35 +179,28 @@ class RequestforQuotation(BuyingController):
|
|||||||
if full_name == "Guest":
|
if full_name == "Guest":
|
||||||
full_name = "Administrator"
|
full_name = "Administrator"
|
||||||
|
|
||||||
# send document dict and some important data from suppliers row
|
|
||||||
# to render message_for_supplier from any template
|
|
||||||
doc_args = self.as_dict()
|
doc_args = self.as_dict()
|
||||||
doc_args.update({"supplier": data.get("supplier"), "supplier_name": data.get("supplier_name")})
|
|
||||||
|
|
||||||
# Get Contact Full Name
|
|
||||||
supplier_name = None
|
|
||||||
if data.get("contact"):
|
if data.get("contact"):
|
||||||
contact_name = frappe.db.get_value(
|
contact = frappe.get_doc("Contact", data.get("contact"))
|
||||||
"Contact", data.get("contact"), ["first_name", "middle_name", "last_name"]
|
doc_args["contact"] = contact.as_dict()
|
||||||
)
|
|
||||||
supplier_name = (" ").join(x for x in contact_name if x) # remove any blank values
|
|
||||||
|
|
||||||
args = {
|
doc_args.update(
|
||||||
"update_password_link": update_password_link,
|
{
|
||||||
"message": frappe.render_template(self.message_for_supplier, doc_args),
|
"supplier": data.get("supplier"),
|
||||||
"rfq_link": rfq_link,
|
"supplier_name": data.get("supplier_name"),
|
||||||
"user_fullname": full_name,
|
"update_password_link": f'<a href="{update_password_link}" class="btn btn-default btn-xs" target="_blank">{_("Set Password")}</a>',
|
||||||
"supplier_name": supplier_name or data.get("supplier_name"),
|
"portal_link": f'<a href="{rfq_link}" class="btn btn-default btn-sm" target="_blank"> {_("Submit your Quotation")} </a>',
|
||||||
"supplier_salutation": self.salutation or "Dear Mx.",
|
"user_fullname": full_name,
|
||||||
}
|
}
|
||||||
|
)
|
||||||
subject = self.subject or _("Request for Quotation")
|
email_template = frappe.get_doc("Email Template", self.email_template)
|
||||||
template = "templates/emails/request_for_quotation.html"
|
message = frappe.render_template(email_template.response_, doc_args)
|
||||||
|
subject = frappe.render_template(email_template.subject, doc_args)
|
||||||
sender = frappe.session.user not in STANDARD_USERS and frappe.session.user or None
|
sender = frappe.session.user not in STANDARD_USERS and frappe.session.user or None
|
||||||
message = frappe.get_template(template).render(args)
|
|
||||||
|
|
||||||
if preview:
|
if preview:
|
||||||
return message
|
return {"message": message, "subject": subject}
|
||||||
|
|
||||||
attachments = self.get_attachments()
|
attachments = self.get_attachments()
|
||||||
|
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
<h4>{{_("Request for Quotation")}}</h4>
|
|
||||||
<p>{{ supplier_salutation if supplier_salutation else ''}} {{ supplier_name }},</p>
|
|
||||||
<p>{{ message }}</p>
|
|
||||||
<p>{{_("The Request for Quotation can be accessed by clicking on the following button")}}:</p>
|
|
||||||
<br>
|
|
||||||
<a
|
|
||||||
href="{{ rfq_link }}"
|
|
||||||
class="btn btn-default btn-sm"
|
|
||||||
target="_blank">
|
|
||||||
{{ _("Submit your Quotation") }}
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
{% if update_password_link %}
|
|
||||||
<br>
|
|
||||||
<p>{{_("Please click on the following button to set your new password")}}:</p>
|
|
||||||
<a
|
|
||||||
href="{{ update_password_link }}"
|
|
||||||
class="btn btn-default btn-xs"
|
|
||||||
target="_blank">
|
|
||||||
{{_("Set Password") }}
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
{% endif %}
|
|
||||||
<p>
|
|
||||||
{{_("Regards")}},<br>
|
|
||||||
{{ user_fullname }}
|
|
||||||
</p>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user