diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e8e2b9b6935ca6ebe7e7664425f0e8d79050daf8..eb2644f440aa9b4df60857a585e704e09e31c0d7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -526,23 +526,6 @@ class Product extends CommonObject { $this->db->begin(); - // Delete supplier prices log - /*if (! $error) - { - $sql = 'DELETE pfpl'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price_log as pfpl, '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; - $sql.= ' WHERE pfpl.fk_product_fournisseur = pfp.rowid'; - $sql.= ' AND pf.fk_product = '.$id; - dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if (! $result) - { - $error++; - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR); - } - }*/ - // Delete supplier prices if (! $error) { @@ -639,6 +622,7 @@ class Product extends CommonObject return 0; } } + return 0; } /** @@ -1018,13 +1002,13 @@ class Product extends CommonObject global $langs, $conf; - dol_syslog("Product::fetch id=$id ref=$ref ref_ext=$ref_ext"); + dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref." ref_ext=".$ref_ext); // Check parameters if (! $id && ! $ref && ! $ref_ext) { $this->error=$langs->trans('ErrorWrongParameters'); - dol_print_error("Product::fetch ".$this->error, LOG_ERR); + dol_print_error(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -1039,7 +1023,7 @@ class Product extends CommonObject else if ($ref) $sql.= " WHERE ref = '".$this->db->escape($ref)."'"; else if ($ref_ext) $sql.= " WHERE ref_ext = '".$this->db->escape($ref_ext)."'"; - dol_syslog("Product::fetch sql=".$sql); + dol_syslog(get_class($this)."::fetch sql=".$sql); $resql = $this->db->query($sql); if ( $resql ) { @@ -2371,7 +2355,7 @@ class Product extends CommonObject /** * Load information about stock of a product into stock_warehouse[] and stock_reel * - * @return int < 0 si erreur, > 0 si ok + * @return int < 0 if KO, > 0 if OK */ function load_stock() { @@ -2381,7 +2365,7 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."product_stock"; $sql.= " WHERE fk_product = '".$this->id."'"; - dol_syslog("Product::load_stock sql=".$sql); + dol_syslog(get_class($this)."::load_stock sql=".$sql); $result = $this->db->query($sql); if ($result) { @@ -2403,7 +2387,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } } diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 40c6dc3cc20db4236be4ec3da593d290e5716c54..7e3f36e6adaf9803003ff1b20a916d5b46188281 100755 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -77,6 +77,8 @@ class ProductTest extends PHPUnit_Framework_TestCase { global $conf,$user,$langs,$db; + if (empty($conf->produit->enabled)) { print __METHOD__." Module Product must be enabled.\n"; die(); } + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. print __METHOD__."\n";