Change order status in module panel


In our solution an order ends up in Attention state when shipment couldn’t be created in Unifaun because of invalid address. We are now creating an order panel for correcting delivery address and then send it to Unifaun again. Sending to Unifaun is currently triggered when an order enters Confirmed state, this means I want to change order state to Confirmed after correcting address, then it will be sent to Unifaun again.

The problem

I can’t change order status in SavePanel method. If I’m using

order.SetOrderStatus((short)OrderState.Confirmed, ModuleECommerce.Instance.AdminToken);

then the order confirmed entry action is triggered but I will get an error

Order (cb8fc1e4-6a1d-4a57-9f66-8a12374979be) has already been changed in the database. Get a new copy of the object and submit your changes again.

and if I’m using

orderCarrier.OrderStatus = (short)OrderState.Confirmed;

then the order confirmed entry action is not triggered.

(I also tried changing delivery to a new delivery state Retry with a related order state Confirmed in StateTransitionBuilder but that will give me the same error as above.)

How can I move order to Confirmed state?

Litium version: 7.3.1-patch-1911150957