Property OrderHistory->id_order_state is empty at line 872 in file classes/ObjectModel.php

Property OrderHistory->id_order_state is empty at line 872 in file classes/ObjectModel.php is appear when you use bank and cheque modules as your prestashop store payment method. Also, because you or your customers add out of stock products to shopping cart.

The solutions for the problem that you could check on your prestashop database is :
1. Look at the ps_order_history table, id_order_state field. All values have to be non-zero in this field. If you don't know, set 8 (Payment error).
2. If there is no zero value on ps_order history table, id_order_state field then check out number 3 below.
3. Check if PS_OS_OUTOFSTOCK_PAID and PS_OS_OUTOFSTOCK_UNPAID are missing from ps_configuration table.
4. If PS_OS_OUTOFSTOCK_PAID and PS_OS_OUTOFSTOCK_UNPAID are missing from ps_configuration table, then you should inserting PS_OS_OUTOFSTOCK_PAID and PS_OS_OUTOFSTOCK_UNPAID in the ps_configuration table.

The above problem occur because the payment method module wants PS_OS_OUTOFSTOCK_PAID or PS_OS_OUTOFSTOCK_UNPAID and because there is no PS_OS_OUTOFSTOCK_PAID or PS_OS_OUTOFSTOCK_UNPAID field on the ps_configuration table, it return an error.