Files added with all functions
This commit is contained in:
parent
27bbb561d2
commit
1276893550
@ -12,11 +12,11 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
'Supplier Quotation': 'Supplier Quotation'
|
'Supplier Quotation': 'Supplier Quotation'
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.fields_dict["suppliers"].grid.get_field("contact").get_query = function(doc, cdt, cdn){
|
frm.fields_dict["suppliers"].grid.get_field("contact").get_query = function(doc, cdt, cdn) {
|
||||||
var d =locals[cdt][cdn];
|
let d = locals[cdt][cdn];
|
||||||
return {
|
return {
|
||||||
query: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_supplier_contacts",
|
query: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_supplier_contacts",
|
||||||
filters: {'supplier': doc.supplier}
|
filters: {'supplier': d.supplier}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -44,13 +44,100 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
freeze: true,
|
freeze: true,
|
||||||
args: {
|
args: {
|
||||||
rfq_name: frm.doc.name
|
rfq_name: frm.doc.name
|
||||||
|
},
|
||||||
|
callback: function(r){
|
||||||
|
frm.reload_doc();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
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({
|
||||||
@ -119,6 +206,29 @@ frappe.ui.form.on("Request for Quotation Supplier",{
|
|||||||
if(!w) {
|
if(!w) {
|
||||||
frappe.msgprint(__("Please enable pop-ups")); return;
|
frappe.msgprint(__("Please enable pop-ups")); return;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
no_quote: function(frm, cdt, cdn) {
|
||||||
|
var d = locals[cdt][cdn];
|
||||||
|
if (d.no_quote) {
|
||||||
|
if (d.quote_status != __('Received')) {
|
||||||
|
frappe.model.set_value(cdt, cdn, 'quote_status', 'No Quote');
|
||||||
|
} else {
|
||||||
|
frappe.msgprint(__("Cannot set a received RFQ to No Quote"));
|
||||||
|
frappe.model.set_value(cdt, cdn, 'no_quote', 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
d.quote_status = __('Pending');
|
||||||
|
frm.call({
|
||||||
|
method:"update_rfq_supplier_status",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
sup_name: d.supplier
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
frm.refresh_field("suppliers");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -144,7 +254,6 @@ erpnext.buying.RequestforQuotationController = erpnext.buying.BuyingController.e
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("Get items from"));
|
}, __("Get items from"));
|
||||||
|
|
||||||
// Get items from Opportunity
|
// Get items from Opportunity
|
||||||
this.frm.add_custom_button(__('Opportunity'),
|
this.frm.add_custom_button(__('Opportunity'),
|
||||||
function() {
|
function() {
|
||||||
@ -160,11 +269,6 @@ erpnext.buying.RequestforQuotationController = erpnext.buying.BuyingController.e
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("Get items from"));
|
}, __("Get items from"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get items from open Material Requests based on supplier
|
// Get items from open Material Requests based on supplier
|
||||||
this.frm.add_custom_button(__('Possible Supplier'), function() {
|
this.frm.add_custom_button(__('Possible Supplier'), function() {
|
||||||
// Create a dialog window for the user to pick their supplier
|
// Create a dialog window for the user to pick their supplier
|
||||||
@ -205,7 +309,7 @@ erpnext.buying.RequestforQuotationController = erpnext.buying.BuyingController.e
|
|||||||
}, __("Get items from"));
|
}, __("Get items from"));
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
calculate_taxes_and_totals: function() {
|
calculate_taxes_and_totals: function() {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user