From 6830fe4f91163ec3c10b59d94428d085ce9dcd32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 13:38:49 +0200 Subject: [PATCH] Fix generic clone function --- htdocs/core/class/commonobject.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ddfb2780f3f..f1ec086cd03 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5023,7 +5023,7 @@ abstract class CommonObject */ public function createFromCloneCommon(User $user, $fromid) { - global $user; + global $user, $langs; $error = 0; @@ -5039,6 +5039,8 @@ abstract class CommonObject $object->id = 0; // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; // ... // Create clone @@ -5046,7 +5048,8 @@ abstract class CommonObject // Other options if ($result < 0) { - $error ++; + $error++; + $this->error = $object->error; $this->errors = $object->errors; dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); }