[fix] Removed customer, supplier and added link_name from website_list_for_contact file
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 4b28ee8..59ad092 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
@@ -15,7 +15,8 @@
frm.fields_dict["suppliers"].grid.get_field("contact").get_query = function(doc, cdt, cdn){
var d =locals[cdt][cdn];
return {
- filters: {'supplier': d.supplier}
+ query: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_supplier_contacts",
+ filters: {'supplier': doc.supplier}
}
}
},
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 6300864..ab9efae 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -159,6 +159,12 @@
list_context["show_sidebar"] = True
return list_context
+def get_supplier_contacts(doctype, txt, searchfield, start, page_len, filters):
+ return frappe.db.sql(""" select `tabContact`.name from `tabContact`, `tabDynamic Link`
+ where `tabDynamic Link`.link_doctype = 'Supplier' and (`tabDynamic Link`.link_name = %(name)s
+ or `tabDynamic Link`.link_name like %(txt)s) and `tabContact`.name = `tabDynamic Link`.parent
+ limit %(start)s, %(page_len)s""", {"start": start, "page_len":page_len, "txt": "%%%s%%" % txt, "name": filters.get('supplier')})
+
# This method is used to make supplier quotation from material request form.
@frappe.whitelist()
def make_supplier_quotation(source_name, for_supplier, target_doc=None):
@@ -289,4 +295,3 @@
}, target_doc)
return target_doc
-
\ No newline at end of file
diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py
index 1abb7e7..6ca20c3 100644
--- a/erpnext/controllers/website_list_for_contact.py
+++ b/erpnext/controllers/website_list_for_contact.py
@@ -100,11 +100,12 @@
def get_customers_suppliers(doctype, user):
meta = frappe.get_meta(doctype)
- contacts = frappe.get_all("Contact", fields=["customer", "supplier", "email_id"],
- filters={"email_id": user})
+ contacts = frappe.db.sql(""" select `tabContact`.email_id, `tabDynamic Link`.link_doctype, `tabDynamic Link`.link_name
+ from `tabContact`, `tabDynamic Link` where
+ `tabContact`.name = `tabDynamic Link`.parent and `tabContact`.email_id =%s """, user, as_dict=1)
- customers = [c.customer for c in contacts if c.customer] if meta.get_field("customer") else None
- suppliers = [c.supplier for c in contacts if c.supplier] if meta.get_field("supplier") else None
+ customers = [c.link_name for c in contacts if c.link_doctype == 'Customer'] if meta.get_field("customer") else None
+ suppliers = [c.link_name for c in contacts if c.link_doctype == 'Supplier'] if meta.get_field("supplier") else None
return customers, suppliers