Need help in customizing BOM

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 .


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}

1 Like

@Ben_Cornwell_Mott . Thanks a lot for the help I already read from one of your post and did changes as per my requirement , but dont know exactly how to make it count the stock available ? Any help ?


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

Do this server side and you can query using set_query.

1 Like

@Ben_Cornwell_Mott. Thanks for the reply . Server side validation always looks complicated , is there a way that I could achieve this with js ?


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”);{
args: {
warehouse: “Stores - VMI”,
posting_date: “”,
posting_time: “”
callback: function(r) {
for (i=r.message.length-1;i >=0; i–)
if (r.message[i].qty <= 0) {
r.message.splice(i, 1);
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.

1 Like

@Ben_Cornwell_Mott . Thanks a lot for guiding me , I will try and let you know what I have done .

Thanks again