Fix: Bug #460 - Wrong entity assignment when creating a warehouse
This commit is contained in:
parent
501dccabc2
commit
6bcf2be91b
@ -2330,11 +2330,16 @@ class Product extends CommonObject
|
||||
*/
|
||||
function load_stock()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->stock_reel = 0;
|
||||
|
||||
$sql = "SELECT reel, fk_entrepot, pmp";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock";
|
||||
$sql.= " WHERE fk_product = '".$this->id."'";
|
||||
$sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."entrepot as w";
|
||||
$sql.= " WHERE w.entity = ".$conf->entity;
|
||||
$sql.= " AND w.rowid = ps.fk_entrepot";
|
||||
$sql.= " AND ps.fk_product = ".$this->id;
|
||||
|
||||
dol_syslog("Product::load_stock sql=".$sql);
|
||||
$result = $this->db->query($sql) ;
|
||||
|
||||
@ -70,6 +70,8 @@ class Entrepot extends CommonObject
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Si libelle non defini, erreur
|
||||
if ($this->libelle == '')
|
||||
{
|
||||
@ -79,8 +81,8 @@ class Entrepot extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (datec, fk_user_author, label)";
|
||||
$sql .= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->db->escape($this->libelle)."')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label)";
|
||||
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate(mktime())."',".$user->id.",'".$this->db->escape($this->libelle)."')";
|
||||
|
||||
dol_syslog("Entrepot::create sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
|
||||
@ -209,6 +209,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print '</tr>';
|
||||
|
||||
// Real stock
|
||||
$product->load_stock();
|
||||
print '<tr><td>'.$langs->trans("PhysicalStock").'</td>';
|
||||
print '<td>'.$product->stock_reel;
|
||||
if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user