For this function to always work, make sure:
The product is a stock item. Otherwise, you cannot remove it from stock at all.
The delivery bill is created in a project, so that you can outsource the delivery bill.
The delivery bill has not been outsourced yet.
You can find more information in our manual: