What a topic! Lack of parts is a refrain (complaint) I hear over and over from customers all over the world. Sometimes there really are very poor spares management practices, sometimes stores has discarded needed materiel, sometimes policy does get in the way, but more often than not there are problems with planning and scheduling being flawed and far too short sighted.
Planners expect the parts to be there, and the stores person needs to be told what spares need to be there. Even with diligence on both "sides", parts unavailability becomes a problem. Of course maintainers taking the issue into their hands will often stash parts in shops, etc. so that they know they have their critical spares. That serves to distort the information available to the stores-keepers so they are then left making decisions about buying on the basis of flawed, incomplete and inaccurate information.
The problem is not so easily solved either because maintainer behavior will need to change, planning forecasts need to be far better than they usually are, and stores needs to get smarter about how it determines quantities to hold, buy and about what is NOT needed in stores any longer.
Consider that parts are a form of insurance against downtime. Insurers don't use simplistic calculations to determine what coverage to offer - there's a whole array of statisticians (actuaries) looking at risks and where to and not to put their money. Most companies don't give anywhere near enough thought to spares, how much to invest in it, which spares to carry to get the most uptime, etc.
You need to know what creates demand - failures and preventive work do most of that. Preventive maintenance should be planned and scheduled with a very easy to forecast demand for spares. Predictive and detective maintenance do not usually consume spares, but they do uncover failures that must be fixed (which usually do consume spares). That demand is also fairly easy to forecast if you use failure statistics to forecast what failures you will find. The only "surprises" should arise from those failures you allow to occur, likely randomly and (if you've done your RCM work) only on assets where some downtime is tolerable.
Fast moving items (fasteners, fittings, electric devices, some bearings, etc.) can be managed with the simpler stores calculations for min / max / EOQ / ROP. Even if you don't forecast these, you can gather usage information based on actual usage. For the slower moving items the data won't build up for a long time so that approach breaks down. Lead times are often longer and those will drive up the need for spares, even with low demand. You need to forecast demand. It is based on failure rates and task frequencies. Clearly, the more of your work is proactive, the more easily you can forecast demand for most items.
If you want to lower your risk of stockouts, then the math gets more complex. Very few companies use the sort of spares calculation tools that are needed and few stores people seem to have the mathematical knowledge to use them. Depending on the simple algorithms built into your CMMS/EAM is just not good enough. The software tools I've seen are not part of any CMMS/EAM - they are stand alone tools that perform the analysis. The results need to be transferred to your stores management software and then the analysis itself needs to be kept up to date. Someone needs to stay on top of the situation and that someone, needs to understand what she / he is doing, not just plugging numbers into formulas.
There's quite a bit of science behind getting it right. Airlines and military organizations manage this reasonably well. They put investment into making sure asset availability is a top priority - like buying insurance. Unfortunately where failures are less critical and only cost us downtime, lost production and the concessional regulatory violation, or accident, we don't typically give this nearly the attention it deserves.