From e8a0385668316abbe9502cd6d52dc4912096afa3 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Thu, 20 Oct 2011 14:09:04 +0000 Subject: [PATCH] // Introduct "PS_ADVANCED_STOCK_MANAGEMENT", the new stock management --- classes/OrderHistory.php | 6 ++++-- install-dev/sql/db_settings_lite.sql | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/classes/OrderHistory.php b/classes/OrderHistory.php index c35d38591..345d7dea7 100644 --- a/classes/OrderHistory.php +++ b/classes/OrderHistory.php @@ -91,8 +91,10 @@ class OrderHistoryCore extends ObjectModel /* If becoming unlogable => removing sale */ else if (!$newOS->logable AND ($oldOrderStatus AND $oldOrderStatus->logable)) ProductSale::removeProductSale($product['id_product'], $product['cart_quantity']); - // The product is removed from the physical stock. $id_warehouse is needed - if ($newOS->shipped == 1 && $oldOrderStatus->shipped == 0) + + if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && !$isValidated AND $newOS->logable AND isset($oldOrderStatus) AND $oldOrderStatus AND $oldOrderStatus->id == Configuration::get('PS_OS_ERROR')) + StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], (int)$product['cart_quantity']); + else if ($newOS->shipped == 1 && $oldOrderStatus->shipped == 0) // The product is removed from the physical stock. $id_warehouse is needed Stock::updateQuantity($product['id_product'], $product['id_product_attribute'], -$product['cart_quantity'], $id_warehouse, $id_order); // @todo If the old order states was "shipped" and the new is "not shipped" the stock is not decremented } diff --git a/install-dev/sql/db_settings_lite.sql b/install-dev/sql/db_settings_lite.sql index deab4ed26..03b31f2c9 100644 --- a/install-dev/sql/db_settings_lite.sql +++ b/install-dev/sql/db_settings_lite.sql @@ -239,7 +239,8 @@ INSERT INTO `PREFIX_configuration` (`id_configuration`, `name`, `value`, `date_a (151, 'PS_SHOP_DEFAULT', '1', NOW(), NOW()), (152, 'PS_CARRIER_DEFAULT_SORT', '0', NOW(), NOW()), (153, 'PS_STOCK_MVT_INC_REASON_DEFAULT', '1', NOW(), NOW()), -(154, 'PS_STOCK_MVT_DEC_REASON_DEFAULT', '2', NOW(), NOW()); +(154, 'PS_STOCK_MVT_DEC_REASON_DEFAULT', '2', NOW(), NOW()), +(155, 'PS_ADVANCED_STOCK_MANAGEMENT', '1', NOW(), NOW()); INSERT INTO `PREFIX_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES (36, 1, 'IN', NOW()),(36, 2, 'FA', NOW()),(36, 3, 'CU', NOW()),(36, 4, 'FA', NOW()),(36, 5, 'FA', NOW()),