Magento orders have different states for following their process (billed, shipped, refunded...) in the order Workflow. These states are not visible in Magento back office. In fact, it is orders statuses that are displayed in back office and not their states.
Each state can have one or several statuses and a status can have only one state. By default, statuses and states have often the same name, that is why it is a little confusing. Here is the list of statuses and states available by default.
|State code||State name||Status code||Status name|
Pending Amazon Simple Pay
|holded||On Hold||holded||On Hold|
For adding new status to a state, you just need to declare it in config.xml file
<!-- Statuses declaration -->
<my_processing_status translate="label"><label>My Processing Status</label></my_processing_status>
<!-- Linking Status to a state -->
When we want to modify order status in some code, we have to be sure that current order state allows status wanted. It is possible to change both state and status with setState method
$state = 'processing';
$status = 'my_processing_status';
$comment = 'Changing state to Processing and status to My Processing Status';
$isCustomerNotified = false;
$order->setState($state, $status, $comment, $isCustomerNotified);
$status can also take false value in order to only set order state, or true value for setting status by taking first status associated to this state.
You can now adjust as you wish your order workflow in Magento.