From 996917926785f867ef013a56a685de1a333ca0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 6 Nov 2015 11:35:39 +0100 Subject: [PATCH] NEW Deprecated Product::setPriceExpression. Use Product::update instead --- htdocs/product/class/product.class.php | 27 +++++--------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cd00f843f61..d7e50da4e06 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -717,6 +717,7 @@ class Product extends CommonObject $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); + $sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); $sql.= " WHERE rowid = " . $id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -1495,33 +1496,15 @@ class Product extends CommonObject * * @param int $expression_id Expression * @return int <0 if KO, >0 if OK + * @deprecated Use Product::update instead */ function setPriceExpression($expression_id) { - global $conf; + global $user; - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; + $this->fk_price_expression = $expression_id; - $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET fk_price_expression = ".$expression_id; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::setPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } + return $this->update($this->id, $user); } /**