Skip to content

Commit

Permalink
FIX: Check stock of product by warehouse if $entrepot_id defined on s…
Browse files Browse the repository at this point in the history
…hippings
  • Loading branch information
fmarcet committed Feb 1, 2016
1 parent acc9879 commit d6cda60
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions htdocs/expedition/class/expedition.class.php
Expand Up @@ -8,6 +8,7 @@
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Francis Appels <francis.appels@yahoo.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -763,13 +764,19 @@ function addline($entrepot_id, $id, $qty)
return -1;
}

if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) // FIXME Check is done for stock of product, it must be done for stock of product into warehouse if $entrepot_id defined
if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT)
{
$product=new Product($this->db);
$result=$product->fetch($fk_product);
if ($entrepot_id > 0) {
$product->load_stock();
$product_stock = $product->stock_warehouse[$entrepot_id]->real;
}
else
$product_stock = $product->stock_reel;
$product_type=$product->type;

if ($product_type == 0 && $product->stock_reel < $qty)
if ($product_type == 0 && $product_stock < $qty)
{
$this->error=$langs->trans('ErrorStockIsNotEnough');
$this->db->rollback();
Expand Down

0 comments on commit d6cda60

Please sign in to comment.