mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 10:11:20 +00:00
refactor: RFQ email process
(cherry picked from commit 9cb5768fea)
# Conflicts:
# erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
# erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
# erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
# erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json
This commit is contained in:
@@ -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) {
|
refresh: function (frm, cdt, cdn) {
|
||||||
if (frm.doc.docstatus === 1) {
|
if (frm.doc.docstatus === 1) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
@@ -248,6 +239,28 @@ frappe.ui.form.on("Request for Quotation", {
|
|||||||
}
|
}
|
||||||
refresh_field("items");
|
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) => {
|
preview: (frm) => {
|
||||||
let dialog = new frappe.ui.Dialog({
|
let dialog = new frappe.ui.Dialog({
|
||||||
title: __("Preview Email"),
|
title: __("Preview Email"),
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"send_attached_files",
|
"send_attached_files",
|
||||||
"send_document_print",
|
"send_document_print",
|
||||||
"sec_break_email_2",
|
"sec_break_email_2",
|
||||||
|
"subject",
|
||||||
"message_for_supplier",
|
"message_for_supplier",
|
||||||
"terms_section_break",
|
"terms_section_break",
|
||||||
"incoterm",
|
"incoterm",
|
||||||
@@ -126,6 +127,7 @@
|
|||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:doc.suppliers.some((item) => item.send_email) && !(doc.docstatus == 1 && !doc.email_template)",
|
||||||
"fieldname": "supplier_response_section",
|
"fieldname": "supplier_response_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Email Details"
|
"label": "Email Details"
|
||||||
@@ -139,8 +141,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
|
<<<<<<< HEAD
|
||||||
"fetch_from": "email_template.response",
|
"fetch_from": "email_template.response",
|
||||||
"fetch_if_empty": 1,
|
"fetch_if_empty": 1,
|
||||||
|
=======
|
||||||
|
"default": "Please supply the specified items at the best possible rates",
|
||||||
|
>>>>>>> 9cb5768fea (refactor: RFQ email process)
|
||||||
"fieldname": "message_for_supplier",
|
"fieldname": "message_for_supplier",
|
||||||
"fieldtype": "Text Editor",
|
"fieldtype": "Text Editor",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
@@ -251,7 +257,7 @@
|
|||||||
"label": "Preview Email"
|
"label": "Preview Email"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"depends_on": "eval:doc.suppliers.some((item) => item.send_email)",
|
||||||
"fieldname": "sec_break_email_2",
|
"fieldname": "sec_break_email_2",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hide_border": 1
|
"hide_border": 1
|
||||||
@@ -315,6 +321,14 @@
|
|||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"label": "Has Unit Price Items",
|
"label": "Has Unit Price Items",
|
||||||
"no_copy": 1
|
"no_copy": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Request for Quotation",
|
||||||
|
"fieldname": "subject",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Subject",
|
||||||
|
"not_nullable": 1,
|
||||||
|
"reqd": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"grid_page_length": 50,
|
"grid_page_length": 50,
|
||||||
@@ -322,7 +336,11 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
|
<<<<<<< HEAD
|
||||||
"modified": "2025-03-03 16:48:39.856779",
|
"modified": "2025-03-03 16:48:39.856779",
|
||||||
|
=======
|
||||||
|
"modified": "2026-01-05 14:27:33.329810",
|
||||||
|
>>>>>>> 9cb5768fea (refactor: RFQ email process)
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Request for Quotation",
|
"name": "Request for Quotation",
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class RequestforQuotation(BuyingController):
|
|||||||
send_attached_files: DF.Check
|
send_attached_files: DF.Check
|
||||||
send_document_print: DF.Check
|
send_document_print: DF.Check
|
||||||
status: DF.Literal["", "Draft", "Submitted", "Cancelled"]
|
status: DF.Literal["", "Draft", "Submitted", "Cancelled"]
|
||||||
|
subject: DF.Data
|
||||||
suppliers: DF.Table[RequestforQuotationSupplier]
|
suppliers: DF.Table[RequestforQuotationSupplier]
|
||||||
tc_name: DF.Link | None
|
tc_name: DF.Link | None
|
||||||
terms: DF.TextEditor | None
|
terms: DF.TextEditor | None
|
||||||
@@ -66,6 +67,10 @@ class RequestforQuotation(BuyingController):
|
|||||||
def before_validate(self):
|
def before_validate(self):
|
||||||
self.set_has_unit_price_items()
|
self.set_has_unit_price_items()
|
||||||
self.flags.allow_zero_qty = self.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):
|
def validate(self):
|
||||||
self.validate_duplicate_supplier()
|
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)
|
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):
|
def validate_duplicate_supplier(self):
|
||||||
supplier_list = [d.supplier for d in self.suppliers]
|
supplier_list = [d.supplier for d in self.suppliers]
|
||||||
if len(supplier_list) != len(set(supplier_list)):
|
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")
|
fixed_procurement_email = frappe.db.get_single_value("Buying Settings", "fixed_email")
|
||||||
if fixed_procurement_email:
|
if fixed_procurement_email:
|
||||||
sender = frappe.db.get_value("Email Account", fixed_procurement_email, "email_id")
|
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
|
sender = frappe.session.user not in STANDARD_USERS and frappe.session.user or None
|
||||||
|
|
||||||
if preview:
|
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 = []
|
attachments = []
|
||||||
if self.send_attached_files:
|
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):
|
def send_email(self, data, sender, subject, message, attachments):
|
||||||
make(
|
make(
|
||||||
|
|||||||
@@ -80,20 +80,29 @@
|
|||||||
"fieldname": "email_id",
|
"fieldname": "email_id",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Email Id",
|
"label": "Email ID",
|
||||||
"no_copy": 1
|
"no_copy": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
|
<<<<<<< HEAD
|
||||||
"modified": "2020-11-04 22:01:43.832942",
|
"modified": "2020-11-04 22:01:43.832942",
|
||||||
|
=======
|
||||||
|
"modified": "2026-01-05 14:08:27.274538",
|
||||||
|
>>>>>>> 9cb5768fea (refactor: RFQ email process)
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Request for Quotation Supplier",
|
"name": "Request for Quotation Supplier",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
|
<<<<<<< HEAD
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
|
=======
|
||||||
|
"row_format": "Dynamic",
|
||||||
|
"sort_field": "creation",
|
||||||
|
>>>>>>> 9cb5768fea (refactor: RFQ email process)
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user