Commerce cart allowing quantity than In stock
commerce stock module check the quantity and prevent add max than stock,also if the stock be 0 it change add to cart button to out of stock.

Also if you want to implement it by yourself you can do it with rules