Merge pull request #5674 from rohitwaghchaure/v7_fixes
[Fixes] RFQ contact and multiple creation of supplier quotation issue
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 6058cb4..e526034 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
@@ -100,8 +100,19 @@
frappe.ui.form.on("Request for Quotation Supplier",{
supplier: function(frm, cdt, cdn) {
var d = locals[cdt][cdn]
- frappe.model.set_value(cdt, cdn, 'contact', '')
- frappe.model.set_value(cdt, cdn, 'email_id', '')
+ frappe.call({
+ method:"erpnext.accounts.party.get_party_details",
+ args:{
+ party: d.supplier,
+ party_type: 'Supplier'
+ },
+ callback: function(r){
+ if(r.message){
+ frappe.model.set_value(cdt, cdn, 'contact', r.message.contact_person)
+ frappe.model.set_value(cdt, cdn, 'email_id', r.message.contact_email)
+ }
+ }
+ })
},
download_pdf: function(frm, cdt, cdn) {
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 eea796a..b01d3e8 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -192,6 +192,8 @@
if isinstance(doc, basestring):
doc = json.loads(doc)
+ validate_duplicate_supplier_quotation(doc)
+
try:
sq_doc = frappe.get_doc({
"doctype": "Supplier Quotation",
@@ -242,4 +244,14 @@
doc = frappe.get_doc(doctype, name)
args = doc.get('suppliers')[cint(supplier_idx) - 1]
doc.update_supplier_part_no(args)
- return doc
\ No newline at end of file
+ return doc
+
+@frappe.whitelist()
+def validate_duplicate_supplier_quotation(args):
+ data = frappe.db.sql("""select sq.name as name from `tabSupplier Quotation` sq,
+ `tabSupplier Quotation Item` sqi where sqi.parent = sq.name and sq.supplier = %(supplier)s
+ and sqi.request_for_quotation = %(rfq)s and sq.docstatus < 2""",
+ {'supplier': args.get('supplier'), 'rfq': args.get('name')}, as_dict=True)
+
+ if data and data[0] and data[0].name:
+ frappe.throw(_("Already supplier quotation has created"))
diff --git a/erpnext/templates/includes/rfq.js b/erpnext/templates/includes/rfq.js
index ea003d8..3e9c261 100644
--- a/erpnext/templates/includes/rfq.js
+++ b/erpnext/templates/includes/rfq.js
@@ -79,6 +79,7 @@
},
btn: this,
callback: function(r){
+ $('.btn-sm').hide()
frappe.unfreeze();
}
})