diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 28d0f004784..1efdad2f43f 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2019-2020 Laurent Destailleur +/* Copyright (C) 2023 Christian Humpel * * 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 @@ -239,7 +240,7 @@ if (empty($reshook)) { $moline->batch = GETPOST('batch-'.$line->id.'-'.$i); $moline->role = 'consumed'; $moline->fk_mrp_production = $line->id; - $moline->fk_stock_movement = $idstockmove; + $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove; $moline->fk_user_creat = $user->id; $resultmoline = $moline->create($user); @@ -924,10 +925,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Stock if (isModEnabled('stock')) { print ''; - if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { - print img_warning($langs->trans('StockTooLow')).' '; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES) && $tmpproduct->type != PRODUCT::TYPE_SERVICE) { + if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { + print img_warning($langs->trans('StockTooLow')) . ' '; + } + print price2num($tmpproduct->stock_reel, 'MS'); // Available } - print price2num($tmpproduct->stock_reel, 'MS'); // Available print ''; } // Lot @@ -1001,7 +1004,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Action delete line if ($permissiontodelete) { - $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line2['rowid']).'&fk_movement='.((int) $line2['fk_stock_movement']); print ''; print ''; print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete');