When I select tools in RFQ and get supplier from tag, data couldn’t fetch, system is show only that tag which I add first time in tag list.
Ex: let’s say when I add tag abc & xyz
And assign that tag to supplier, after that I add 1 more tag aaa, in RFQ I select tools and get supplier from tag, so the system is show on first two tag, not showing another tag.
opened 04:23PM - 05 Jul 21 UTC
bug
When I select tools in RFQ and get supplier from tag, data couldn't fetch, syste… m is show only that tag which I add first time in tag list.
Ex: let's say when I add tag abc & xyz
And assign that tag to supplier, after that I add 1 more tag aaa, in RFQ I select tools and get supplier from tag, so the system is show on first two tag, not showing another tag
I have solved this issue via a custom script
frappe.ui.form.on("Request for Quotation", "refresh", function(frm) {
var doc = frm.doc;
//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) {
console.log("r.message --- ", r.message);
if(r.message) {
for (var i = 0; i < r.message.length; i++) {
var exists = false;
console.log("r.message[i] --- ", r.message[i].constructor);
if (r.message[i].constructor === Array){
var supplier = r.message[i][0];
} else {
var supplier = r.message[i].name;
}
console.log("doc", doc);
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");
}
frm.add_custom_button("Get Suppliers from Tag", function() {
let d = new frappe.ui.Dialog({
title: 'Get Suppliers from Tag',
fields: [
{
label: 'Tag',
fieldname: 'tag',
fieldtype: 'Link',
options: 'Tag'
}
],
primary_action_label: 'Add Suppliers',
primary_action(values) {
console.log(values);
frappe.call({
type: "GET",
method: "frappe.desk.doctype.tag.tag.get_tagged_docs",
args: {
"doctype": "Supplier",
"tag": values.tag
},
callback: load_suppliers
});
d.hide();
}
});
d.show();
});
});