From 11fa7a931109c86a35b96e65cf5fe291fe2c23ca Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 14 Mar 2017 13:26:10 +0530 Subject: [PATCH] [fix] Removed customer, supplier and added link_name from website_list_for_contact file --- .../request_for_quotation/request_for_quotation.js | 3 ++- .../request_for_quotation/request_for_quotation.py | 7 ++++++- erpnext/controllers/website_list_for_contact.py | 9 +++++---- 3 files changed, 13 insertions(+), 6 deletions(-) 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 4b28ee854b..59ad092724 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 @@ frappe.ui.form.on("Request for Quotation",{ 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 630086436f..ab9efaed31 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 @@ def get_list_context(context=None): 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 @@ def get_item_from_material_requests_based_on_supplier(source_name, target_doc = }, 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 1abb7e7475..6ca20c3506 100644 --- a/erpnext/controllers/website_list_for_contact.py +++ b/erpnext/controllers/website_list_for_contact.py @@ -100,11 +100,12 @@ def post_process(doctype, data): 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