When we want to cancel a document containing products with lots we follow the following procedure:

1. We cancel the document normally by copying it  for example to credit note .So the items are removed from the warehouse. But the corresponding batches are not released.

2. We open the original document (what we canceled), unlock, select the line of the item we want, right-click on the lots and click “Disconnect from lots”