diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 958f14f8911..2cffecfaf96 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos GarcĂ­a - * Copyright (C) 2015-2016 Ferran Marcet + * Copyright (C) 2015-2017 Ferran Marcet * * 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 @@ -2253,11 +2253,11 @@ class Contrat extends CommonObject $this->context['createfromclone'] = 'createfromclone'; $error = 0; - $now = dol_now(); $this->fetch($this->id); // Load dest object $clonedObj = clone $this; + $clonedObj->socid = $socid; $this->db->begin(); @@ -2292,16 +2292,13 @@ class Contrat extends CommonObject $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } else { - // copy internal contacts - if ($clonedObj->copy_linked_contact($this, 'internal') < 0) - $error ++; - - // copy external contacts if same company - elseif ($this->socid == $clonedObj->socid) { - if ($clonedObj->copy_linked_contact($this, 'external') < 0) - $error ++; - } - } + // copy external contacts if same company + if ($this->socid == $clonedObj->socid) { + if ($clonedObj->copy_linked_contact($this, 'external') < 0) { + $error++; + } + } + } if (! $error) { foreach ( $this->lines as $line ) {