March 10, 20179 yr Hello. I want to share with you a bug that I have detected. [Conditions] - Advanced Stock Management: Activated. To reproduce the bug just follow the steps: Create a supply order. Add a product with quantity equal 0 and choose for example order 2 new products. Current instant state: Physical quantity = 0 | Usable quantity = 0 | Real quantity = 0 Change the status to Order Validated. Current instant state: Physical quantity = 0 | Usable quantity = 0 | Real quantity = 0 Change the status to Pending Receipt. Current instant state: Physical quantity = 0 | Usable quantity = 0 | Real quantity = 2 Go to the front office. You can see that there are 2 items to be ordered when you haven't received the products: I guess is a heritated bug from Prestashop. But I think can produce severe problems in many stores. If the supplier needs 5 days to deliver your order, you can be in serious troubles with your customers :) I have been taking a look in the code, and I think the problem must be in the AdminSupplyOrdersController.php line 1223: ``` // create stock entry if not exist when order is in pendingreceipt if ($newstate->pendingreceipt) { $supplyorderdetails = $supplyorder->getEntries(); foreach ($supplyorderdetails as $supplyorderdetail) { $ispresent = Stock::productIsPresentInStock($supplyorderdetail['idproduct'], $supplyorderdetail['idproductattribute'], $supplyorder->idwarehouse); if (!$is_present) { $stock = new Stock(); $stock_params = array( 'id_product_attribute' => $supply_order_detail['id_product_attribute'], 'id_product' => $supply_order_detail['id_product'], 'physical_quantity' => 0, 'price_te' => $supply_order_detail['price_te'], 'usable_quantity' => 0, 'id_warehouse' => $supply_order->id_warehouse ); // saves stock in warehouse $stock->hydrate($stock_params); $stock->add(); } } ``` I hope this can help to fix the bug. Thank you very much and regards.
Create an account or sign in to comment