From b222800012bbdb5ff0c8329d10fea991aa35f77b Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 23 Sep 2015 15:14:08 +0200 Subject: [PATCH 1/2] FIX clone customer order create new order with validate ref and not with PROV --- htdocs/commande/class/commande.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 767bf294d6f..567c3f1a702 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -988,14 +988,16 @@ class Commande extends CommonOrder $this->ref_client = ''; // Set ref - require_once DOL_DOCUMENT_ROOT ."/core/modules/commande/".$conf->global->COMMANDE_ADDON.'.php'; - $obj = $conf->global->COMMANDE_ADDON; - $modCommande = new $obj; - $this->ref = $modCommande->getNextValue($objsoc,$this); - + $this->ref = '(PROV)'; // Create clone $result=$this->create($user); + if ($result < 0) $error++; + + // Set new ref + $newref='(PROV'.$this->id.')'; + $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($newref)."' WHERE rowid=".$this->id; + $result=$this->db->query($sql); if ($result < 0) $error++; if (! $error) From f385f8bcfa1c44930e46c94430d76b9aa9deba3f Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Oct 2015 14:34:34 +0100 Subject: [PATCH 2/2] FIX better fix to generate a PROV ref after clone --- htdocs/commande/class/commande.class.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 567c3f1a702..fff3f64de8d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -978,6 +978,7 @@ class Commande extends CommonOrder } $this->id=0; + $this->ref = ''; $this->statut=self::STATUS_DRAFT; // Clear fields @@ -986,18 +987,9 @@ class Commande extends CommonOrder $this->date_creation = ''; $this->date_validation = ''; $this->ref_client = ''; - - // Set ref - $this->ref = '(PROV)'; - + // Create clone $result=$this->create($user); - if ($result < 0) $error++; - - // Set new ref - $newref='(PROV'.$this->id.')'; - $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($newref)."' WHERE rowid=".$this->id; - $result=$this->db->query($sql); if ($result < 0) $error++; if (! $error)