The decisions on facility location are not only important in the industrial sector, such as determining the location of construction of factories and power plants, the deployment of equipment and departments in an industrial unit, the establishment of offices in cities, product distribution centers, etc., but also in the public and service sector, such as the location of police stations, emergency services, buses, restaurants, banks, health and medical sector, and so on. Since making better models can help more in achieving the desired goals, this paper examines and develops one of the important issues in ‘facility location-allocation’ called Capacitated P-Median Problem (CPMP). In this paper, by developing the CPMP mathematical planning model, we try to model the problem in a way that the service to customers according to the service level is effective in the optimum solution, and to some extent, brings CPMP closer to actual circumstances. Adding the service level will convert CPMP from a deterministic state to a stochastic model in which demands can have any distribution function. If the customer demand follows the normal distribution function, this stochastic model can be converted to a Mixed Integer Nonlinear Programming. This obtained model is used in a real case study, to develop tanks of an oil refinery so that the costs are minimized and the customer demand is met at an acceptable level. Also, comparing the new model with traditional CPMP Model through solving the real case study shows the power of the proposed model.