|
@@ -307,6 +307,7 @@ if (empty($reshook)) {
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';*/
|
|
|
|
|
|
if (GETPOST('addline', 'alpha')) {
|
|
|
+ $qty= (GETPOST('qtytoadd') != '' ? price2num(GETPOST('qtytoadd', 'MS')) : null);
|
|
|
if ($fk_warehouse <= 0) {
|
|
|
$error++;
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
|
|
@@ -323,12 +324,17 @@ if (empty($reshook)) {
|
|
|
$tmpproduct = new Product($db);
|
|
|
$result = $tmpproduct->fetch($fk_product);
|
|
|
|
|
|
- if (!$error && $tmpproduct->status_batch && !$batch) {
|
|
|
+ if (empty($error) && $tmpproduct->status_batch>0 && empty($batch)) {
|
|
|
$error++;
|
|
|
$langs->load("errors");
|
|
|
setEventMessages($langs->trans("ErrorProductNeedBatchNumber", $tmpproduct->ref), null, 'errors');
|
|
|
}
|
|
|
- if (!$error && !$tmpproduct->status_batch && $batch) {
|
|
|
+ if (empty($error) && $tmpproduct->status_batch==2 && !empty($batch) && $qty>1) {
|
|
|
+ $error++;
|
|
|
+ $langs->load("errors");
|
|
|
+ setEventMessages($langs->trans("TooManyQtyForSerialNumber", $tmpproduct->ref, $batch), null, 'errors');
|
|
|
+ }
|
|
|
+ if (empty($error) && empty($tmpproduct->status_batch) && !empty($batch)) {
|
|
|
$error++;
|
|
|
$langs->load("errors");
|
|
|
setEventMessages($langs->trans("ErrorProductDoesNotNeedBatchNumber", $tmpproduct->ref), null, 'errors');
|
|
@@ -341,7 +347,7 @@ if (empty($reshook)) {
|
|
|
$tmp->fk_product = $fk_product;
|
|
|
$tmp->batch = $batch;
|
|
|
$tmp->datec = $now;
|
|
|
- $tmp->qty_view = (GETPOST('qtytoadd') != '' ? price2num(GETPOST('qtytoadd', 'MS')) : null);
|
|
|
+ $tmp->qty_view = $qty;
|
|
|
|
|
|
$result = $tmp->create($user);
|
|
|
if ($result < 0) {
|