Merge pull request #10922 from altatof/cloneorder
clone of order like in propal (ref_client, contacts)
This commit is contained in:
commit
31963be6a0
@ -1075,7 +1075,7 @@ class Commande extends CommonOrder
|
|||||||
*/
|
*/
|
||||||
public function createFromClone($socid = 0)
|
public function createFromClone($socid = 0)
|
||||||
{
|
{
|
||||||
global $user,$hookmanager;
|
global $conf, $user,$hookmanager;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -1116,13 +1116,32 @@ class Commande extends CommonOrder
|
|||||||
$this->date_commande = dol_now();
|
$this->date_commande = dol_now();
|
||||||
$this->date_creation = '';
|
$this->date_creation = '';
|
||||||
$this->date_validation = '';
|
$this->date_validation = '';
|
||||||
$this->ref_client = '';
|
if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = '';
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$this->context['createfromclone'] = 'createfromclone';
|
$this->context['createfromclone'] = 'createfromclone';
|
||||||
$result=$this->create($user);
|
$result=$this->create($user);
|
||||||
if ($result < 0) $error++;
|
if ($result < 0) $error++;
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
// copy internal contacts
|
||||||
|
if ($this->copy_linked_contact($objFrom, 'internal') < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
// copy external contacts if same company
|
||||||
|
if ($this->socid == $objFrom->socid)
|
||||||
|
{
|
||||||
|
if ($this->copy_linked_contact($objFrom, 'external') < 0)
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Hook of thirdparty module
|
// Hook of thirdparty module
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user