FIX: Check stock of batch on shippment
This commit is contained in:
parent
e22664b8cf
commit
6260c1ae9e
@ -8,6 +8,7 @@
|
|||||||
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||||
* Copyright (C) 2014 Francis Appels <francis.appels@yahoo.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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -237,7 +238,7 @@ if (empty($reshook))
|
|||||||
$ret=$object->addline_batch($batch_line[$i]);
|
$ret=$object->addline_batch($batch_line[$i]);
|
||||||
if ($ret < 0)
|
if ($ret < 0)
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$object->error.'</div>';
|
$mesg='<div class="error">'.$object->errorsToString().'</div>';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2014-2015 Francis Appels <francis.appels@yahoo.com>
|
* Copyright (C) 2014-2015 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -857,6 +858,7 @@ class Expedition extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function addline_batch($dbatch)
|
function addline_batch($dbatch)
|
||||||
{
|
{
|
||||||
|
global $conf,$langs;
|
||||||
$num = count($this->lines);
|
$num = count($this->lines);
|
||||||
if ($dbatch['qty']>0)
|
if ($dbatch['qty']>0)
|
||||||
{
|
{
|
||||||
@ -882,7 +884,17 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT)
|
if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT)
|
||||||
{
|
{
|
||||||
// TODO
|
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
|
||||||
|
$prod_batch = new Productbatch($this->db);
|
||||||
|
$prod_batch->fetch($value['id_batch']);
|
||||||
|
|
||||||
|
if ($prod_batch->qty < $linebatch->dluo_qty)
|
||||||
|
{
|
||||||
|
$this->errors[] = $langs->trans('ErrorStockIsNotEnough');
|
||||||
|
dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR);
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump($linebatch);
|
//var_dump($linebatch);
|
||||||
@ -895,6 +907,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
//var_dump($line);
|
//var_dump($line);
|
||||||
$this->lines[$num] = $line;
|
$this->lines[$num] = $line;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user