From 0dc3d1b996c74a14e1eac942e5fbedda94fb59c3 Mon Sep 17 00:00:00 2001 From: vChabot Date: Wed, 6 Jun 2012 09:37:06 +0000 Subject: [PATCH] [-] BO : BugFix : #PSCFV-2644 : Unable to remove stock to a product with advanced stock management git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15870 b9a71923-0436-4b27-9f14-aed3839534dd --- .../admin/AdminStockManagementController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminStockManagementController.php b/controllers/admin/AdminStockManagementController.php index aec30adf1..01dc486b7 100644 --- a/controllers/admin/AdminStockManagementController.php +++ b/controllers/admin/AdminStockManagementController.php @@ -356,7 +356,7 @@ class AdminStockManagementControllerCore extends AdminController 'size' => 10, 'maxlength' => 6, 'required' => true, - 'desc' => $this->l('Physical quantity to remove') + 'desc' => $this->l('Physical quantity to remove'), ), array( 'type' => 'radio', @@ -676,7 +676,17 @@ class AdminStockManagementControllerCore extends AdminController Tools::redirectAdmin($redirect.'&conf=2'); } else - $this->errors[] = Tools::displayError('It is not possible to remove the specified quantity or an error occurred. No stock was removed.'); + { + $physical_quantity_in_stock = (int)$stock_manager->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), false); + $usable_quantity_in_stock = (int)$stock_manager->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), true); + $not_usable_quantity = ($physical_quantity_in_stock - $usable_quantity_in_stock); + if ($usable_quantity_in_stock < $quantity) + $this->errors[] = sprintf(Tools::displayError('You don\'t have enough usable quantity (usable or not). Could not remove %d out of %d.'), (int)$quantity, (int)$usable_quantity_in_stock); + else if ($not_usable_quantity < $quantity) + $this->errors[] = sprintf(Tools::displayError('You don\'t have enough quantity (not usable). Could not remove %d out of %d.'), (int)$quantity, (int)$not_usable_quantity); + else + $this->errors[] = Tools::displayError('It is not possible to remove the specified quantity or an error occurred. No stock was removed.'); + } } }