When you sell a product via the Fee Sheet, it’s taken from inventory. If you don’t have enough in inventory, or if what’s needed is expired, or must be taken from multiple lots but that is not allowed, then you will get this message.
See the sellDrug() function in interface/drugs/drugs.inc.php for the relevant logic.