I have the following code that would create a shipment for an order. But still the shipped item isn't marked as shipped. And SHIP button at the top is still there. Therefore, I cant create RMA if needed.
Please check screenshot (link)
$order = Mage::getModel('sales/order') -> loadByIncrementId($order_id);
$itemQty = $order -> getItemsCollection() -> count();
$convertOrder = new Mage_Sales_Model_Convert_Order();
$shipment = Mage::getModel('sales/service_order', $order) -> prepareShipment($itemQty);
$items = $order -> getAllItems();
foreach ($items as $item) {
$shipped_item = $convertOrder -> itemToShipmentItem($item);
$shipped_item -> setQty($item -> getQtyOrdered());
$shipment -> addItem($shipped_item);
}
$shipment -> register();
$shipment -> setOrder($order);
$shipment -> save();