Filter warehouse to only show ones that have stock

Would it be possible to create a custom script to filter warehouses so that only ones that have stock can be shown in ‘source warehouse’ in the stock entry?

Also, when creating a batch from an item, to fetch the item code?