My guess it may have smth to do with UpdateGoodsReceiptsAvailQty(). (I am not sure why is the purpose of this)
You can probably comment out it and see what happens.
Hello!
You can mark it as closed as option. If document is connected with other documents you can not delete it so you will not be able to delete PO, as you will not be able to remove Goods receipt...