New: Can set qty to 0 on order and invoice.

Fix: Clone of order was broken.
This commit is contained in:
Laurent Destailleur 2009-07-15 23:04:05 +00:00
parent 085d564144
commit 8d88035eaf
2 changed files with 14 additions and 12 deletions

View File

@ -567,7 +567,7 @@ class Commande extends CommonObject
*/ */
for ($i = 0 ; $i < sizeof($this->lines) ; $i++) for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
{ {
$resql = $this->addline( $result = $this->addline(
$this->id, $this->id,
$this->lines[$i]->desc, $this->lines[$i]->desc,
$this->lines[$i]->subprice, $this->lines[$i]->subprice,
@ -583,11 +583,12 @@ class Commande extends CommonObject
$this->lines[$i]->date_end, $this->lines[$i]->date_end,
$this->lines[$i]->product_type $this->lines[$i]->product_type
); );
if ($resql < 0) if ($result < 0)
{ {
$this->error=$this->db->error; $this->error=$this->db->lasterror();
dol_print_error($this->db); dol_print_error($this->db);
break; $this->db->rollback();
return -1;
} }
} }
@ -739,7 +740,7 @@ class Commande extends CommonObject
// Clean parameters // Clean parameters
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=0;
if (! $info_bits) $info_bits=0; if (! $info_bits) $info_bits=0;
$pu_ht=price2num($pu_ht); $pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc); $pu_ttc=price2num($pu_ttc);
@ -818,8 +819,6 @@ class Commande extends CommonObject
} }
else else
{ {
$this->error=$this->db->error();
dol_syslog("Error sql=$sql, error=".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -827,6 +826,7 @@ class Commande extends CommonObject
else else
{ {
$this->error=$ligne->error; $this->error=$ligne->error;
dol_syslog("Commande::addline error=".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -1157,7 +1157,7 @@ class Commande extends CommonObject
$ligne->date_end = $this->db->jdate($objp->date_end); $ligne->date_end = $this->db->jdate($objp->date_end);
$this->lignes[$i] = $ligne; // For backward compatibility $this->lignes[$i] = $ligne; // For backward compatibility
$this->lines[$i] = $line; $this->lines[$i] = $ligne;
$i++; $i++;
} }
$this->db->free($result); $this->db->free($result);
@ -1731,7 +1731,8 @@ class Commande extends CommonObject
// Nettoyage parametres // Nettoyage parametres
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=0;
if (! $info_bits) $info_bits=0;
$pu = price2num($pu); $pu = price2num($pu);
$txtva=price2num($txtva); $txtva=price2num($txtva);
@ -2397,6 +2398,7 @@ class CommandeLigne
global $langs, $conf, $user; global $langs, $conf, $user;
dol_syslog("CommandeLigne::insert rang=".$this->rang); dol_syslog("CommandeLigne::insert rang=".$this->rang);
$this->db->begin(); $this->db->begin();
$rangtouse=$this->rang; $rangtouse=$this->rang;
@ -2457,7 +2459,7 @@ class CommandeLigne
else { $sql.='null'; } else { $sql.='null'; }
$sql.= ')'; $sql.= ')';
dol_syslog("CommandeLigne::insert sql=$sql"); dol_syslog("CommandeLigne::insert sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -1512,7 +1512,7 @@ class Facture extends CommonObject
// Clean parameters // Clean parameters
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=0;
if (! $ventil) $ventil=0; if (! $ventil) $ventil=0;
if (! $info_bits) $info_bits=0; if (! $info_bits) $info_bits=0;
$pu_ht=price2num($pu_ht); $pu_ht=price2num($pu_ht);
@ -1635,7 +1635,7 @@ class Facture extends CommonObject
// Clean parameters // Clean parameters
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=0;
$pu = price2num($pu); $pu = price2num($pu);
$txtva=price2num($txtva); $txtva=price2num($txtva);