// Orders : fixed stock (available quantity & Stock)
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11491 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1362,7 +1362,7 @@ class CartCore extends ObjectModel
|
||||
if ($stock_management_active && (int)$product['advanced_stock_management'] == 1)
|
||||
{
|
||||
$warehouse_list = Warehouse::getProductWarehouseList($product['id_product'], $product['id_product_attribute'], $this->id_shop);
|
||||
if (count($warehouse_list) == 0)
|
||||
if (count($warehouse_list) == 0)
|
||||
$warehouse_list = Warehouse::getProductWarehouseList($product['id_product'], $product['id_product_attribute']);
|
||||
// Does the product is in stock ?
|
||||
// If yes, get only warehouse where the product is in stock
|
||||
|
||||
@@ -85,8 +85,6 @@ class OrderHistoryCore extends ObjectModel
|
||||
&& $oldOrderStatus->logable))
|
||||
{
|
||||
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
|
||||
// @since 1.5.0
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
/* If becoming unlogable => removing sale */
|
||||
else if (!$newOS->logable
|
||||
@@ -95,7 +93,8 @@ class OrderHistoryCore extends ObjectModel
|
||||
{
|
||||
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
|
||||
// @since 1.5.0
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
||||
if ($newOS->id == Configuration::get('PS_OS_ERROR') || $newOS->id == Configuration::get('PS_OS_CANCELED'))
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
|
||||
if ((!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') || (int)$product['advanced_stock_management'] != 1)
|
||||
@@ -113,8 +112,7 @@ class OrderHistoryCore extends ObjectModel
|
||||
&& $oldOrderStatus instanceof OrderState
|
||||
&& $oldOrderStatus->shipped == 0
|
||||
&& Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')
|
||||
&& (int)$product['advanced_stock_management'] == 1
|
||||
)
|
||||
&& (int)$product['advanced_stock_management'] == 1)
|
||||
{
|
||||
$manager = StockManagerFactory::getManager();
|
||||
$warehouse = new Warehouse($product['id_warehouse']);
|
||||
@@ -142,12 +140,12 @@ class OrderHistoryCore extends ObjectModel
|
||||
)
|
||||
{
|
||||
$manager = StockManagerFactory::getManager();
|
||||
$mvts = StockMvt::getNegativeStockMvts($order->id, $product['product_id'], $product['product_attribute_id'], $product['cart_quantity']);
|
||||
$mvts = StockMvt::getNegativeStockMvts($order->id, $product['product_id'], $product['product_attribute_id'], $product['product_quantity']);
|
||||
foreach ($mvts as $mvt)
|
||||
{
|
||||
$manager->addProduct(
|
||||
$product['product_id'],
|
||||
$product['id_product_attribute'],
|
||||
$product['product_attribute_id'],
|
||||
new Warehouse($mvt['id_warehouse']),
|
||||
$mvt['physical_quantity'],
|
||||
null,
|
||||
|
||||
@@ -140,7 +140,6 @@ class StockAvailableCore extends ObjectModel
|
||||
foreach ($ids_product_attribute as $id_product_attribute)
|
||||
{
|
||||
$quantity = $manager->getProductRealQuantities($id_product, $id_product_attribute, $warehouses, true);
|
||||
|
||||
$query = array(
|
||||
'table' => _DB_PREFIX_.'stock_available',
|
||||
'data' => array('quantity' => $quantity),
|
||||
|
||||
@@ -465,9 +465,10 @@ class StockManagerCore implements StockManagerInterface
|
||||
$query->leftJoin('order_history', 'oh', 'oh.id_order = o.id_order AND oh.date_add = o.date_upd');
|
||||
$query->leftJoin('order_state', 'os', 'os.id_order_state = oh.id_order_state');
|
||||
$query->where('os.shipped != 1');
|
||||
$query->where('o.valid = 1');
|
||||
// @FIXME: Once part-shipping is done, remove the comment on the line below.
|
||||
// $query->where('o.id_warehouse IN (0, '.implode(', ', $ids_warehouse).')');
|
||||
$query->where('o.valid = 1 OR (os.id_order_state != '.(int)Configuration::get('PS_OS_ERROR').'
|
||||
AND os.id_order_state != '.(int)Configuration::get('PS_OS_CANCELED').')');
|
||||
//if (count($ids_warehouse))
|
||||
//$query->where('od.id_warehouse IN('.implode(', ', $ids_warehouse).')');
|
||||
$client_orders_qty = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
|
||||
// Gets supply_orders_qty
|
||||
|
||||
@@ -165,7 +165,8 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
'size' => 40,
|
||||
'maxlength' => 45,
|
||||
'required' => true,
|
||||
'desc' => $this->l('Name of this warehouse')
|
||||
'desc' => $this->l('Name of this warehouse'),
|
||||
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"<22>{}_$%:',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
|
||||
Reference in New Issue
Block a user