diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 498fa314315..f72b4d54003 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3522,6 +3522,7 @@ abstract class CommonObject if ($elementTable == 'user') $fieldstatus = "statut"; if ($elementTable == 'expensereport') $fieldstatus = "fk_statut"; if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus = "status"; + if (is_array($this->fields) && array_key_exists('status', $this->fields)) $fieldstatus = 'status'; $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql .= " SET ".$fieldstatus." = ".$status; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 362f04105ec..840e46c9c1c 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -192,7 +192,7 @@ if (empty($reshook)) setEventMessages($stockmove->error, $stockmove->errors, 'errors'); } } -var_dump('eee '.$error); + if (! $error) { $pos = 0; // Record consumption @@ -254,7 +254,7 @@ var_dump('eee '.$error); setEventMessages($stockmove->error, $stockmove->errors, 'errors'); } } - var_dump('fff '.$error); + if (! $error) { $pos = 0; // Record production @@ -289,9 +289,13 @@ var_dump('eee '.$error); $qtyremaintoconsume = 0; $qtyremaintoproduce = 0; if ($qtyremaintoconsume == 0 && $qtyremaintoproduce == 0) { - $object->setStatut($object::STATUS_INPROGRESS); + $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_MO_PRODUCED'); } else { - $object->setStatut($object::STATUS_PRODUCED); + $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); + } + if ($result <= 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -524,12 +528,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'consumeandproduceall') { $defaultstockmovementlabel = GETPOST('inventorylabel', 'alphanohtml') ? GETPOST('inventorylabel', 'alphanohtml') : $langs->trans("ProductionForRefAndDate", $object->ref, dol_print_date(dol_now(), 'standard')); - $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog'); + //$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog'); + $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref; print '