[ bug #70 ] Champ Stock toujours vide dans export produit

This commit is contained in:
Laurent Destailleur 2012-10-17 20:30:17 +02:00
parent 33540cb2e8
commit a41186b4c5
2 changed files with 11 additions and 2 deletions

View File

@ -204,8 +204,15 @@ class Entrepot extends CommonObject
$sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
$resql1=$this->db->query($sql);
// Update denormalized fields because we change content of produt_stock
$sql = "UPDATE ".MAIN_DB_PREFIX."product p SET p.stock= (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock ps WHERE ps.fk_product = p.rowid)";
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql2=$this->db->query($sql);
if ($resql1 && $resql2)
{
$this->db->commit();
return 1;

View File

@ -194,6 +194,8 @@ class MouvementStock
{
$sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty;
$sql.= " WHERE rowid = ".$fk_product;
// May be this request is better:
// UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);
dol_syslog(get_class($this)."::_create sql=".$sql);
$resql=$this->db->query($sql);