Task 672 : add stock limitation on shipment + translation

This commit is contained in:
Maxime Kohlhaas 2014-03-15 14:59:27 +01:00
parent b6a2fa61c8
commit 1911f6fcdc
4 changed files with 25 additions and 3 deletions

View File

@ -1104,7 +1104,7 @@ class Commande extends CommonOrder
}
$product_type=$type;
if ($fk_product)
if (!empty($fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($fk_product);

View File

@ -2067,7 +2067,7 @@ class Facture extends CommonInvoice
}
$product_type=$type;
if ($fk_product)
if (!empty($fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($fk_product);

View File

@ -710,12 +710,33 @@ class Expedition extends CommonObject
*/
function addline($entrepot_id, $id, $qty)
{
global $conf, $langs;
$num = count($this->lines);
$line = new ExpeditionLigne($this->db);
$line->entrepot_id = $entrepot_id;
$line->origin_line_id = $id;
$line->qty = $qty;
if($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) {
$orderline = new OrderLine($this->db);
$orderline->fetch($id);
$fk_product = $orderline->fk_product;
if (!empty($orderline->fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($fk_product);
$product_type=$product->type;
if($product_type == 0 && $product->stock_reel < $qty) {
$this->error=$langs->trans('ErrorStockIsNotEnough');
$this->db->rollback();
return -3;
}
}
}
$this->lines[$num] = $line;
}

View File

@ -22,4 +22,5 @@ ToAndDate=To___________________________________ on ____/_____/__________
GoodStatusDeclaration=Have received the goods above in good condition,
Deliverer=Deliverer :
Sender=Sender
Recipient=Recipient
Recipient=Recipient
ErrorStockIsNotEnough=There's not enough stock