fix: changed dialog field to select

This commit is contained in:
Anurag Mishra 2019-05-28 16:15:04 +05:30
parent 351e9983cf
commit 5afe9f2200
2 changed files with 43 additions and 10 deletions

View File

@ -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"
},
]
});

View File

@ -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