From 8267dbd084852c545a610e2a1b985de33d3caf2c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 7 Apr 2011 12:32:29 +0000 Subject: [PATCH] Fix: do not uptate total with special product line --- htdocs/comm/propal/class/propal.class.php | 6 +++--- htdocs/core/class/commonobject.class.php | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7c148fde453..238d85a4c73 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -400,7 +400,7 @@ class Propal extends CommonObject if ($result > 0) { // Mise a jour informations denormalisees au niveau de la propale meme - $result=$this->update_price(); + $result=$this->update_price(1); if ($result > 0) { $this->db->commit(); @@ -500,7 +500,7 @@ class Propal extends CommonObject $result=$this->db->query($sql); if ($result > 0) { - $this->update_price(); + $this->update_price(1); $this->fk_propal = $this->id; $this->rowid = $rowid; @@ -546,7 +546,7 @@ class Propal extends CommonObject if ($line->delete($lineid)) { - $this->update_price(); + $this->update_price(1); return 1; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 138957adc4e..801958aa872 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -978,10 +978,11 @@ class CommonObject } /** - * Update total_ht, total_ttc and total_vat for an object (sum of lines) - * @return int <0 if KO, >0 if OK + * Update total_ht, total_ttc and total_vat for an object (sum of lines) + * @param exclspec Exclude special product (product_type=9) + * @return int <0 if KO, >0 if OK */ - function update_price() + function update_price($exclspec=0) { include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); @@ -1000,6 +1001,7 @@ class CommonObject $sql = 'SELECT qty, total_ht, '.$fieldtva.' as total_tva, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2, total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; + if ($exclspec) $sql.= ' AND product_type <> 9'; dol_syslog("CommonObject::update_price sql=".$sql); $resql = $this->db->query($sql);