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 fd04b0d2a6..76775343e4 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -354,3 +354,31 @@ def get_supplier_tag(): frappe.cache().hset("Supplier", "Tags", tags) return frappe.cache().hget("Supplier", "Tags") + +@frappe.whitelist() +@frappe.validate_and_sanitize_search_inputs +def get_rfq_containing_supplier(doctype, txt, searchfield, start, page_len, filters): + conditions = "" + if txt: + conditions += "and rfq.name like '%%"+txt+"%%' " + + if filters.get("transaction_date"): + conditions += "and rfq.transaction_date = '{0}'".format(filters.get("transaction_date")) + + rfq_data = frappe.db.sql(""" + select + distinct rfq.name, rfq.transaction_date, + rfq.company + from + `tabRequest for Quotation` rfq, `tabRequest for Quotation Supplier` rfq_supplier + where + rfq.name = rfq_supplier.parent + and rfq_supplier.supplier = '{0}' + and rfq.docstatus = 1 + and rfq.company = '{1}' + {2} + order by rfq.transaction_date ASC + limit {3} offset {4} """ \ + .format(filters.get("supplier"), filters.get("company"), conditions, page_len, start), as_dict=1) + + return rfq_data \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 4a2a0786f3..3376e82956 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -62,8 +62,10 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext transaction_date: null }, get_query_filters: { - docstatus: 1, - } + supplier: me.frm.doc.supplier + }, + get_query_method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_rfq_containing_supplier" + }) }, __("Get items from")); }