diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js index 6ab5048082e..411af3ea374 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -34,15 +34,6 @@ frappe.ui.form.on("Request for Quotation", { }); }, - onload: function (frm) { - if (!frm.doc.message_for_supplier) { - frm.set_value( - "message_for_supplier", - __("Please supply the specified items at the best possible rates") - ); - } - }, - refresh: function (frm, cdt, cdn) { if (frm.doc.docstatus === 1) { frm.add_custom_button( @@ -248,6 +239,28 @@ frappe.ui.form.on("Request for Quotation", { } refresh_field("items"); }, +<<<<<<< HEAD +======= + + email_template(frm) { + if (frm.doc.email_template) { + frappe.db + .get_value("Email Template", frm.doc.email_template, [ + "use_html", + "response", + "response_html", + "subject", + ]) + .then((r) => { + frm.set_value( + "message_for_supplier", + r.message.use_html ? r.message.response_html : r.message.response + ); + frm.set_value("subject", r.message.subject); + }); + } + }, +>>>>>>> 9cb5768fea (refactor: RFQ email process) preview: (frm) => { let dialog = new frappe.ui.Dialog({ title: __("Preview Email"), diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json index 824484f9c20..41192505a54 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json @@ -30,6 +30,7 @@ "send_attached_files", "send_document_print", "sec_break_email_2", + "subject", "message_for_supplier", "terms_section_break", "incoterm", @@ -126,6 +127,7 @@ "reqd": 1 }, { + "depends_on": "eval:doc.suppliers.some((item) => item.send_email) && !(doc.docstatus == 1 && !doc.email_template)", "fieldname": "supplier_response_section", "fieldtype": "Section Break", "label": "Email Details" @@ -139,8 +141,12 @@ }, { "allow_on_submit": 1, +<<<<<<< HEAD "fetch_from": "email_template.response", "fetch_if_empty": 1, +======= + "default": "Please supply the specified items at the best possible rates", +>>>>>>> 9cb5768fea (refactor: RFQ email process) "fieldname": "message_for_supplier", "fieldtype": "Text Editor", "in_list_view": 1, @@ -251,7 +257,7 @@ "label": "Preview Email" }, { - "depends_on": "eval:!doc.__islocal", + "depends_on": "eval:doc.suppliers.some((item) => item.send_email)", "fieldname": "sec_break_email_2", "fieldtype": "Section Break", "hide_border": 1 @@ -315,6 +321,14 @@ "hidden": 1, "label": "Has Unit Price Items", "no_copy": 1 + }, + { + "default": "Request for Quotation", + "fieldname": "subject", + "fieldtype": "Data", + "label": "Subject", + "not_nullable": 1, + "reqd": 1 } ], "grid_page_length": 50, @@ -322,7 +336,11 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2025-03-03 16:48:39.856779", +======= + "modified": "2026-01-05 14:27:33.329810", +>>>>>>> 9cb5768fea (refactor: RFQ email process) "modified_by": "Administrator", "module": "Buying", "name": "Request for Quotation", diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index e8c5690cf6f..fa63eb23c91 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -56,6 +56,7 @@ class RequestforQuotation(BuyingController): send_attached_files: DF.Check send_document_print: DF.Check status: DF.Literal["", "Draft", "Submitted", "Cancelled"] + subject: DF.Data suppliers: DF.Table[RequestforQuotationSupplier] tc_name: DF.Link | None terms: DF.TextEditor | None @@ -66,6 +67,10 @@ class RequestforQuotation(BuyingController): def before_validate(self): self.set_has_unit_price_items() self.flags.allow_zero_qty = self.has_unit_price_items +<<<<<<< HEAD +======= + self.set_data_for_supplier() +>>>>>>> 9cb5768fea (refactor: RFQ email process) def validate(self): self.validate_duplicate_supplier() @@ -90,6 +95,22 @@ class RequestforQuotation(BuyingController): not row.qty for row in self.get("items") if (row.item_code and not row.qty) ) +<<<<<<< HEAD +======= + def set_data_for_supplier(self): + if self.email_template: + data = frappe.get_value( + "Email Template", + self.email_template, + ["use_html", "response", "response_html", "subject"], + as_dict=True, + ) + if not self.message_for_supplier: + self.message_for_supplier = data.response_html if data.use_html else data.response + if not self.subject: + self.subject = data.subject + +>>>>>>> 9cb5768fea (refactor: RFQ email process) def validate_duplicate_supplier(self): supplier_list = [d.supplier for d in self.suppliers] if len(supplier_list) != len(set(supplier_list)): @@ -283,12 +304,6 @@ class RequestforQuotation(BuyingController): } ) - if not self.email_template: - return - - email_template = frappe.get_doc("Email Template", self.email_template) - message = frappe.render_template(email_template.response_, doc_args) - subject = frappe.render_template(email_template.subject, doc_args) fixed_procurement_email = frappe.db.get_single_value("Buying Settings", "fixed_email") if fixed_procurement_email: sender = frappe.db.get_value("Email Account", fixed_procurement_email, "email_id") @@ -296,7 +311,12 @@ class RequestforQuotation(BuyingController): sender = frappe.session.user not in STANDARD_USERS and frappe.session.user or None if preview: - return {"message": message, "subject": subject} + return { + "message": self.message_for_supplier, + "subject": self.subject + or frappe.get_value("Email Template", self.email_template, "subject") + or _("Request for Quotation"), + } attachments = [] if self.send_attached_files: @@ -316,7 +336,15 @@ class RequestforQuotation(BuyingController): ) ) - self.send_email(data, sender, subject, message, attachments) + self.send_email( + data, + sender, + self.subject + or frappe.get_value("Email Template", self.email_template, "subject") + or _("Request for Quotation"), + self.message_for_supplier, + attachments, + ) def send_email(self, data, sender, subject, message, attachments): make( diff --git a/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json b/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json index 534cd90cc65..6a8fbd17f1d 100644 --- a/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json +++ b/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json @@ -80,20 +80,29 @@ "fieldname": "email_id", "fieldtype": "Data", "in_list_view": 1, - "label": "Email Id", + "label": "Email ID", "no_copy": 1 } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], +<<<<<<< HEAD "modified": "2020-11-04 22:01:43.832942", +======= + "modified": "2026-01-05 14:08:27.274538", +>>>>>>> 9cb5768fea (refactor: RFQ email process) "modified_by": "Administrator", "module": "Buying", "name": "Request for Quotation Supplier", "owner": "Administrator", "permissions": [], +<<<<<<< HEAD "sort_field": "modified", +======= + "row_format": "Dynamic", + "sort_field": "creation", +>>>>>>> 9cb5768fea (refactor: RFQ email process) "sort_order": "DESC", "track_changes": 1 -} \ No newline at end of file +}