Filter Source Warehouse based on stock where located in Item

Dear Community,
In Stock Entry Doctype, While selecting Item code the source Warehouse only show where the stock is available not need to show all warehouses.

Here Example My Item Code is Notebook with pen and that stock located in Inside Office Warehouse While selecting the item code inside warehouse should be appear not need all ware house in filter.


Stock available in Inside office.


here i need only inside office as filter.

Based on Stock source warehouse show appear.Kindly help to solve this customize.

Thanks in Advance.

@NCP can you please help me to solve this

Hi @Mohamed2335
Please read this document. I hope you will help
https://frappeframework.com/docs/user/en/guides/app-development/overriding-link-query-by-custom-script

Thank You!

sir i tried it not work maybe i dont know to implement can anyone pls share code type,its help me a lot.

Hi @Mohamed2335
Try this code

frappe.ui.form.on('Stock Entry', {
	refresh:function(frm) {
		frm.set_query("s_warehouse", "items", function(doc, cdt, cdn) {
			var row = locals[cdt][cdn];
            return {
                "filters": {
                	'parent_warehouse': 'VF 01 - S'
            	}
            }
        })

	}
})

Thank You!

Thanks for your Response,my default warehouse is Stores-WAE but it not works
i had two main warehouse Stores-WAE,Office - WAE and also in that warehouse they has sub warehouse name that one is Inside Office i mentioned above with pics. Inside Office comes under Stores-WAE

frappe.ui.form.on(‘Stock Entry’, {
refresh: function(frm) {
frm.set_query(“s_warehouse”, “items”, function(doc, cdt, cdn) {
return {
filters: {
‘parent_warehouse’: ‘Stores - WAE’
}
};
});
}
});

Hi @Mohamed2335
Bro your code on my side is the perfect work


Thank You!

This code am used,
frappe.ui.form.on(‘Stock Entry’, {
refresh: function(frm) {
frm.set_query(“s_warehouse”, “items”, function(doc, cdt, cdn) {
return {
filters: {
‘parent_warehouse’: ‘Stores - WAE’
}
};
});
}
});


here instead of option its only show inside office.bcs this stock only available in Inside Office.

can i miss any thing.