Hi ,
Could anyone tell me how to do this ?
I want only the items which is in stock to be displayed when I add items to the BOM .
Thanks
Hi ,
Could anyone tell me how to do this ?
I want only the items which is in stock to be displayed when I add items to the BOM .
Thanks
You probably can do this with a custom script:
cur_frm.fields_dict[āitemsā].grid.get_field(āitem_codeā).get_query = function(doc, cdt, cdn) {
return {
filters:{ādefault_supplierā: doc.supplier}
}
}
@Ben_Cornwell_Mott . Thanks a lot for the help I already read from one of your post https://discuss.frappe.io/t/need-help-customizing-bom/13758 and did changes as per my requirement , but dont know exactly how to make it count the stock available ? Any help ?
Thanks
Looking at it closer, I donāt think get_query will work.
I think your best bet is to create a custom query, like the ones in
erpnext/erpnext/controllers/queries.py
Do this server side and you can query using set_query.
@Ben_Cornwell_Mott. Thanks for the reply . Server side validation always looks complicated , is there a way that I could achieve this with js ?
Thanks
I havenāt seen an example of how to filter a list purely through js, but it likely would be very slow. I started working on some code which derives the list of in stock parts, but I canāt get the list to actually filter:
cur_frm.set_query(āitem_codeā,āitemsā, function(frm,cdt,cdn){
console.log(āGot HEREā);
frappe.call({
method:āerpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_itemsā,
args: {
warehouse: āStores - VMIā,
posting_date: āā,
posting_time: āā
},
callback: function(r) {
console.log(r);
for (i=r.message.length-1;i >=0; iā)
{
if (r.message[i].qty <= 0) {
r.message.splice(i, 1);
}
}
console.log(r);
return r.message;
}
});
}
);
To be clear, the above is not a working solution, but the start of something, maybe. I think server side would be far easier.
@Ben_Cornwell_Mott . Thanks a lot for guiding me , I will try and let you know what I have done .
Thanks again