Fix delete not used empty stock record
When removing all stock from warehouse are move all stock to other warehouse, there is still an 0 stock record in in the stock table for the source warehouse, not visible in Dolibarr.
This commit is contained in:
parent
3108523ff2
commit
1d85529eda
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
|
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
|
||||||
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||||
|
* Copyright (C) 2015 Francis Appels <francis.appels@z-application.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -233,6 +234,36 @@ class MouvementStock extends CommonObject
|
|||||||
$fk_product_stock = $this->db->last_insert_id(MAIN_DB_PREFIX."product_stock");
|
$fk_product_stock = $this->db->last_insert_id(MAIN_DB_PREFIX."product_stock");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete empty stock record
|
||||||
|
$sql = "SELECT reel FROM ".MAIN_DB_PREFIX."product_stock";
|
||||||
|
$sql.= " WHERE rowid = ".$fk_product_stock;
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
if ($obj->reel == 0)
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::_create delete 0 stock record", LOG_DEBUG);
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock";
|
||||||
|
$sql.= " WHERE rowid = ".$fk_product_stock;
|
||||||
|
$delsql=$this->db->query($sql);
|
||||||
|
if (! $delsql)
|
||||||
|
{
|
||||||
|
$this->errors[]=$this->db->lasterror();
|
||||||
|
$error = -8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors[]=$this->db->lasterror();
|
||||||
|
$error = -7;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update detail stock for sell-by date
|
// Update detail stock for sell-by date
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user