diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 17fae31ef7d..30031103156 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -294,12 +294,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); - } // Confirmation of validation if ($action == 'validate') diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index b3163511150..90e23dad802 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -240,9 +240,10 @@ class BOM extends CommonObject unset($object->import_key); // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - + $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; + // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b331c479670..01ed67cce3e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7476,6 +7476,7 @@ abstract class CommonObject { $sql="UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE ref = '(PROV)' AND rowid = ".$this->id; $resqlupdate = $this->db->query($sql); + if ($resqlupdate===false) { $error++; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d6474a480dc..4fbdd101c35 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -283,8 +283,9 @@ class MyObject extends CommonObject // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index a3c49fcd3c8..b013d300845 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -246,10 +246,10 @@ class Mo extends CommonObject unset($object->fk_user_creat); unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0)