Add Get Suppliers dialog (#10025)
* Add Get Suppliers dialog * Commonize code, use depends_on * Update request_for_quotation.js
This commit is contained in:
parent
4cccdbdbf9
commit
05e51d6c83
@ -54,6 +54,91 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get_suppliers_button: function (frm) {
|
||||||
|
var doc = frm.doc;
|
||||||
|
var dialog = new frappe.ui.Dialog({
|
||||||
|
title: __("Get Suppliers"),
|
||||||
|
fields: [
|
||||||
|
{ "fieldtype": "Select", "label": __("Get Suppliers By"),
|
||||||
|
"fieldname": "search_type",
|
||||||
|
"options": "Tag\nSupplier Type", "reqd": 1 },
|
||||||
|
{ "fieldtype": "Link", "label": __("Supplier Type"),
|
||||||
|
"fieldname": "supplier_type",
|
||||||
|
"options": "Supplier Type", "reqd": 0,
|
||||||
|
"depends_on": "eval:doc.search_type == 'Supplier Type'"},
|
||||||
|
{ "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"},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.fields_dict.add_suppliers.$input.click(function() {
|
||||||
|
var args = dialog.get_values();
|
||||||
|
if(!args) return;
|
||||||
|
dialog.hide();
|
||||||
|
|
||||||
|
//Remove blanks
|
||||||
|
for (var j = 0; j < frm.doc.suppliers.length; j++) {
|
||||||
|
if(!frm.doc.suppliers[j].hasOwnProperty("supplier")) {
|
||||||
|
frm.get_field("suppliers").grid.grid_rows[j].remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_suppliers(r) {
|
||||||
|
if(r.message) {
|
||||||
|
for (var i = 0; i < r.message.length; i++) {
|
||||||
|
var exists = false;
|
||||||
|
if (r.message[i].constructor === Array){
|
||||||
|
var supplier = r.message[i][0];
|
||||||
|
} else {
|
||||||
|
var supplier = r.message[i].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 0; j < doc.suppliers.length;j++) {
|
||||||
|
if (supplier === doc.suppliers[j].supplier) {
|
||||||
|
exists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!exists) {
|
||||||
|
var d = frm.add_child('suppliers');
|
||||||
|
d.supplier = supplier;
|
||||||
|
frm.script_manager.trigger("supplier", d.doctype, d.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frm.refresh_field("suppliers");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.search_type === "Tag" && args.tag) {
|
||||||
|
return frappe.call({
|
||||||
|
type: "GET",
|
||||||
|
method: "frappe.desk.tags.get_tagged_docs",
|
||||||
|
args: {
|
||||||
|
"doctype": "Supplier",
|
||||||
|
"tag": args.tag
|
||||||
|
},
|
||||||
|
callback: load_suppliers
|
||||||
|
});
|
||||||
|
} else if (args.supplier_type) {
|
||||||
|
return frappe.call({
|
||||||
|
method: "frappe.client.get_list",
|
||||||
|
args: {
|
||||||
|
doctype: "Supplier",
|
||||||
|
order_by: "name",
|
||||||
|
fields: ["name"],
|
||||||
|
filters: [["Supplier", "supplier_type", "=", args.supplier_type]]
|
||||||
|
|
||||||
|
},
|
||||||
|
callback: load_suppliers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
make_suppplier_quotation: function(frm) {
|
make_suppplier_quotation: function(frm) {
|
||||||
var doc = frm.doc;
|
var doc = frm.doc;
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Series",
|
"label": "Series",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -59,7 +59,7 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Company",
|
"label": "Company",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -156,7 +156,7 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Date",
|
"label": "Date",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -236,6 +236,36 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "get_suppliers_button",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Get Suppliers",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -406,7 +436,7 @@
|
|||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Message for Supplier",
|
"label": "Message for Supplier",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -786,7 +816,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-06-13 14:29:13.171291",
|
"modified": "2017-07-21 14:06:46.309322",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Request for Quotation",
|
"name": "Request for Quotation",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user