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 46126ed3d6..9ad06f9b7e 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -59,18 +59,38 @@ frappe.ui.form.on("Request for Quotation",{ var dialog = new frappe.ui.Dialog({ title: __("Get Suppliers"), fields: [ - { "fieldtype": "Select", "label": __("Get Suppliers By"), + { + "fieldtype": "Select", "label": __("Get Suppliers By"), "fieldname": "search_type", - "options": "Tag\nSupplier Group", "reqd": 1 }, - { "fieldtype": "Link", "label": __("Supplier Group"), + "options": ["Tag","Supplier Group"], + "reqd": 1, + onchange() { + if(dialog.get_value('search_type') == 'Tag'){ + frappe.call({ + method: 'erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_supplier_tag', + }).then(r => { + dialog.set_df_property("tag", "options", r.message) + }); + } + } + }, + { + "fieldtype": "Link", "label": __("Supplier Group"), "fieldname": "supplier_group", - "options": "Supplier Group", "reqd": 0, - "depends_on": "eval:doc.search_type == 'Supplier Group'"}, - { "fieldtype": "Data", "label": __("Tag"), - "fieldname": "tag", "reqd": 0, - "depends_on": "eval:doc.search_type == 'Tag'" }, - { "fieldtype": "Button", "label": __("Add All Suppliers"), - "fieldname": "add_suppliers", "cssClass": "btn-primary"}, + "options": "Supplier Group", + "reqd": 0, + "depends_on": "eval:doc.search_type == 'Supplier Group'" + }, + { + "fieldtype": "Select", "label": __("Tag"), + "fieldname": "tag", + "reqd": 0, + "depends_on": "eval:doc.search_type == 'Tag'", + }, + { + "fieldtype": "Button", "label": __("Add All Suppliers"), + "fieldname": "add_suppliers" + }, ] }); 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 d57cd7d873..fc7dd72e55 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -341,3 +341,16 @@ def get_item_from_material_requests_based_on_supplier(source_name, target_doc = }, target_doc) return target_doc + +@frappe.whitelist() +def get_supplier_tag(): + data = frappe.db.sql("select _user_tags from `tabSupplier`") + print("data:", data) + tags = [] + for tag in data: + tags += filter(bool, tag[0].split(",")) + + tags = list(set(tags)) + + return tags +