diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 70934e01ed6..9db16a1ee75 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1418,6 +1418,7 @@ class BookKeeping extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); global $user; + $error = 0; $object = new BookKeeping($this->db); @@ -1432,6 +1433,7 @@ class BookKeeping extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -1441,6 +1443,8 @@ class BookKeeping extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } + unset($object->context['createfromclone']); + // End if (! $error) { $this->db->commit(); @@ -1449,7 +1453,7 @@ class BookKeeping extends CommonObject } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 22e24703bc3..335a9f6e9d1 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -238,6 +238,8 @@ class Asset extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index aef77513e7b..2d0ba61fff9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -490,8 +490,6 @@ class ActionComm extends CommonObject { global $db, $user, $langs, $conf, $hookmanager; - $this->context['createfromclone']='createfromclone'; - $error=0; $now=dol_now(); @@ -524,7 +522,8 @@ class ActionComm extends CommonObject } // Create clone - $result=$this->create($fuser); + $this->context['createfromclone']='createfromclone'; + $result=$this->create($fuser); if ($result < 0) $error++; if (! $error) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 11708c3b4ca..b807ea23334 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -279,8 +279,6 @@ class Mailing extends CommonObject $object=new Mailing($this->db); - $object->context['createfromclone']='createfromclone'; - $this->db->begin(); // Load source object @@ -314,6 +312,7 @@ class Mailing extends CommonObject } // Create clone + $object->context['createfromclone']='createfromclone'; $result=$object->create($user); // Other options @@ -345,7 +344,6 @@ class Mailing extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles "; $sql.= " WHERE fk_mailing = ".$fromid; - dol_syslog(get_class($this)."::createFromClone", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 196d6f50451..2c5c2cfd5ce 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1222,8 +1222,6 @@ class Propal extends CommonObject dol_include_once('/projet/class/project.class.php'); - $this->context['createfromclone']='createfromclone'; - $error=0; $now=dol_now(); @@ -1284,6 +1282,7 @@ class Propal extends CommonObject if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = ''; // Create clone + $this->context['createfromclone']='createfromclone'; $result=$clonedObj->create($user); if ($result < 0) $error++; else diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5b3f8006345..d8aed383905 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1066,8 +1066,6 @@ class Commande extends CommonOrder $error=0; - $this->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // get lines so they will be clone @@ -1108,6 +1106,7 @@ class Commande extends CommonOrder $this->ref_client = ''; // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 9efdf3932ff..dc9c1d242e8 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -280,8 +280,6 @@ class BankCateg // extends CommonObject $object = new BankCateg($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -290,6 +288,7 @@ class BankCateg // extends CommonObject $object->statut = 0; // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f980266226c..2fb31440e56 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -951,8 +951,6 @@ class Facture extends CommonInvoice $error=0; - $this->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // get extrafields so they will be clone @@ -962,8 +960,6 @@ class Facture extends CommonInvoice // Load source object $objFrom = clone $this; - - // Change socid if needed if (! empty($socid) && $socid != $this->socid) { @@ -1008,6 +1004,7 @@ class Facture extends CommonInvoice } // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; else { diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index e7ea4779d10..55a3e40b55f 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -404,8 +404,6 @@ class PaymentTerm // extends CommonObject $object=new PaymentTerm($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -417,6 +415,7 @@ class PaymentTerm // extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -430,7 +429,7 @@ class PaymentTerm // extends CommonObject //{ //} - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 710bea7def2..9e13ffcd8a5 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -369,6 +369,7 @@ class Cchargesociales // ... // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -378,6 +379,8 @@ class Cchargesociales dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } + unset($this->context['createfromclone']); + // End if (!$error) { $this->db->commit(); @@ -386,7 +389,7 @@ class Cchargesociales } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index d3c265150d4..74ddce68230 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -459,8 +459,6 @@ class PaymentSocialContribution extends CommonObject $object=new PaymentSocialContribution($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -472,6 +470,7 @@ class PaymentSocialContribution extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -488,7 +487,7 @@ class PaymentSocialContribution extends CommonObject } - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c543e8a0720..5929ec034d1 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2388,8 +2388,6 @@ class Contrat extends CommonObject dol_include_once('/projet/class/project.class.php'); - $this->context['createfromclone'] = 'createfromclone'; - $error = 0; $this->fetch($this->id); @@ -2440,6 +2438,7 @@ class Contrat extends CommonObject } // Create clone + $clonedObj->context['createfromclone'] = 'createfromclone'; $result = $clonedObj->create($user); if ($result < 0) { $error ++; @@ -2479,7 +2478,7 @@ class Contrat extends CommonObject } } - unset($this->context['createfromclone']); + unset($clonedObj->context['createfromclone']); // End if (! $error) { diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b8b4237cc93..63fc671d797 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -202,7 +202,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd) { if ($object->id > 0) { - // Because createFromClone modifies the object, we must clone it so that we can restore it later + // Because createFromClone modifies the object, we must clone it so that we can restore it later if error $orig = clone $object; $result=$object->createFromClone($user, $object->id); diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index f4e74128747..95c642772e2 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -427,6 +427,7 @@ class Ctyperesource // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -436,6 +437,8 @@ class Ctyperesource dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); @@ -444,7 +447,7 @@ class Ctyperesource } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index b30f79f0bba..3a1fba460c4 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -207,6 +207,8 @@ class EmailSenderProfile extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 6873bff157e..f619befab0d 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -757,8 +757,6 @@ class Cronjob extends CommonObject $object=new Cronjob($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -770,6 +768,7 @@ class Cronjob extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -782,10 +781,9 @@ class Cronjob extends CommonObject //if (! $error) //{ - //} - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index b0e3a80b082..662b165ddf4 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -419,8 +419,6 @@ class PaymentDonation extends CommonObject $object=new PaymentDonation($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -432,6 +430,7 @@ class PaymentDonation extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -444,11 +443,9 @@ class PaymentDonation extends CommonObject if (! $error) { - - } - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 781833169dd..efc5af1310c 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -732,6 +732,7 @@ class EcmFiles extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -741,6 +742,8 @@ class EcmFiles extends CommonObject dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index c86b575855a..e00adfad724 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -274,6 +274,8 @@ class EmailCollector extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 620795870a0..ccf811f7607 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -247,6 +247,8 @@ class EmailCollectorAction extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index ddf68ce9512..cafde3a820c 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -222,6 +222,8 @@ class EmailCollectorFilter extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index dc2516822e7..a8e5f80244c 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -315,8 +315,6 @@ class ExpenseReport extends CommonObject if (empty($fk_user_author)) $fk_user_author = $user->id; - $this->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // get extrafields so they will be clone @@ -339,6 +337,7 @@ class ExpenseReport extends CommonObject $this->date_validation = ''; // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 605affed253..3055984e6c7 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -421,8 +421,6 @@ class PaymentExpenseReport extends CommonObject $object=new PaymentExpenseReport($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -434,6 +432,7 @@ class PaymentExpenseReport extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -446,11 +445,9 @@ class PaymentExpenseReport extends CommonObject if (! $error) { - - } - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 32643b77811..e20d8e1da1a 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1118,8 +1118,6 @@ class Fichinter extends CommonObject $error=0; - $this->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // get extrafields so they will be clone @@ -1158,6 +1156,7 @@ class Fichinter extends CommonObject $this->ref_client = ''; // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9f17e9afdf2..38fa5b53699 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1417,8 +1417,6 @@ class CommandeFournisseur extends CommonOrder $error=0; - $this->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -1439,6 +1437,7 @@ class CommandeFournisseur extends CommonOrder $this->date_approve2 = ''; // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index c7b5d00c797..c73c6d86d42 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -463,6 +463,7 @@ class CommandeFournisseurDispatch extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -475,9 +476,10 @@ class CommandeFournisseurDispatch extends CommonObject if (! $error) { - } + unset($object->context['createfromclone']); + // End if (! $error) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 28c20af9371..7fc0bba0bdf 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2489,8 +2489,6 @@ class FactureFournisseur extends CommonInvoice $object=new FactureFournisseur($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -2521,6 +2519,7 @@ class FactureFournisseur extends CommonInvoice } // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -2533,8 +2532,6 @@ class FactureFournisseur extends CommonInvoice if (! $error) { - - } unset($object->context['createfromclone']); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 6029fc7d3f9..e2f31319ca2 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -276,6 +276,8 @@ class MyObject extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index eb4fc32baed..d16c6ccc6ec 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -338,8 +338,6 @@ class Productbatch extends CommonObject $object=new Productbatch($this->db); - $object->context['createfromclone']='createfromclone'; - $this->db->begin(); // Load source object @@ -351,6 +349,7 @@ class Productbatch extends CommonObject // ... // Create clone + $object->context['createfromclone']='createfromclone'; $result=$object->create($user); // Other options @@ -363,7 +362,6 @@ class Productbatch extends CommonObject if (! $error) { - } unset($object->context['createfromclone']); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 3079fef5412..d39849780c1 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -907,8 +907,6 @@ class Productcustomerprice extends CommonObject $object = new Productcustomerprice($this->db); - $object->context['createfromclone']='createfromclone'; - $this->db->begin(); // Load source object @@ -920,6 +918,7 @@ class Productcustomerprice extends CommonObject // ... // Create clone + $object->context['createfromclone']='createfromclone'; $result = $object->create($user); // Other options @@ -929,6 +928,7 @@ class Productcustomerprice extends CommonObject } if (! $error) { + } unset($object->context['createfromclone']); diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index b5d2d639ae4..3aeae37249c 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -582,6 +582,7 @@ class Propalmergepdfproduct extends CommonObject // ... // Create clone + $object->context['createfromclone']='createfromclone'; $result=$object->create($user); // Other options @@ -594,9 +595,10 @@ class Propalmergepdfproduct extends CommonObject if (! $error) { - } + unset($object->context['createfromclone']); + // End if (! $error) { diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 1bc98d32d93..076e3392bc0 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -247,6 +247,8 @@ class Inventory extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index d61630eb88e..60ce7bc02d2 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -454,6 +454,7 @@ class Productlot extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -463,6 +464,8 @@ class Productlot extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index f76f5eeec9c..c5c66ad8d50 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -443,6 +443,7 @@ class ProductStockEntrepot extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -452,6 +453,8 @@ class ProductStockEntrepot extends CommonObject dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index 73242c9aa32..3594773e7f8 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -269,6 +269,8 @@ class CompanyPaymentMode extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 78f934ecf2f..153959938e5 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -240,6 +240,8 @@ class SocieteAccount extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 82b8b09220d..5d4fbed5e72 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1176,6 +1176,7 @@ class SupplierProposal extends CommonObject $this->ref = $modSupplierProposal->getNextValue($objsoc,$this); // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; @@ -1191,6 +1192,8 @@ class SupplierProposal extends CommonObject } } + unset($this->context['createfromclone']); + // End if (! $error) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index d26206e2b5c..43002f30f99 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -966,6 +966,7 @@ class Ticket extends CommonObject // Clear fields // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -977,6 +978,8 @@ class Ticket extends CommonObject if (!$error) { } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 7fd906044f6..fd2aaad8621 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -598,6 +598,7 @@ class Website extends CommonObject // Create new file $objectpagenew = $objectpageold->createFromClone($user, $pageid, $objectpageold->pageurl, '', 0, $object->id, 1); + //print $pageid.' = '.$objectpageold->pageurl.' -> '.$objectpagenew->id.' = '.$objectpagenew->pageurl.'
'; if (is_object($objectpagenew) && $objectpagenew->pageurl) { @@ -646,6 +647,8 @@ class Website extends CommonObject } } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 3c166c1d1f8..ffa2176f142 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -447,6 +447,8 @@ class WebsitePage extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit();