Merge pull request #17773 from Anurag810/request_to_quatation_fix
fix: Changed dialog field to Select when we get supplier in request to quotation
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 46126ed..9ad06f9 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 @@
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 d57cd7d..a10ce46 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 @@
}, target_doc)
return target_doc
+
+@frappe.whitelist()
+def get_supplier_tag():
+ data = frappe.db.sql("select _user_tags from `tabSupplier`")
+
+ tags = []
+ for tag in data:
+ tags += filter(bool, tag[0].split(","))
+
+ tags = list(set(tags))
+
+ return tags
+