title: Magento 2: Unable change order status back to Processing from Complete
body: <p>For debug purposes, I need to change the status of some orders back to Processing, after they've been already shipped, so the status is Complete. </p>
  
  <p>I'm trying to do this programmatically, so I deleted the shipments of the order, and also the Invoices, but I cannot force the status to get back to Processing and it remains Complete.</p>
  
  <p>Is it possible to do it, or once the status is complete, one cannot go back in the status flow? </p>
  
  <p>Just a snippet of code: </p>
  
  <pre><code>protected function deleteShipments(){
      foreach($this-&gt;_ordersToProcess as $incrementId){
          $myOrder = $this-&gt;_order-&gt;loadByIncrementId($incrementId);
  
          if($this-&gt;_registry-&gt;registry('isSecureArea')){
              $this-&gt;_registry-&gt;unregister('isSecureArea');
          }
          $this-&gt;_registry-&gt;register('isSecureArea', true);
  
          $_shipments = $myOrder-&gt;getShipmentsCollection();
  
          if($_shipments){
              foreach($_shipments as $_shipment){
                  $_shipment-&gt;delete();
              }
          }   
  
          $_invoices = $myOrder-&gt;getInvoiceCollection();
  
          if($_invoices){
              foreach($_invoices as $invoice){
                  $invoice-&gt;delete();
              }
          }
  
          $myOrder-&gt;setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true)-&gt;setStatus(\Magento\Sales\Model\Order::STATE_PROCESSING, true); 
          $myOrder-&gt;save();
      }
  
  }
  </code></pre>