Merge pull request #5993 from fappels/develop-product-delete-batch

Fix Delete from product_batch on product delete
This commit is contained in:
Laurent Destailleur 2016-11-22 19:33:07 +01:00 committed by GitHub
commit 12350f180a

View File

@ -925,6 +925,22 @@ class Product extends CommonObject
// End call triggers // End call triggers
} }
// Delete from product_batch on product delete
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch';
$sql.= " WHERE fk_product_stock IN (";
$sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock';
$sql.= " WHERE fk_product = ".$id.")";
dol_syslog(get_class($this).'::delete', LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result)
{
$error++;
$this->errors[] = $this->db->lasterror();
}
}
// Delete all child tables // Delete all child tables
if (! $error) if (! $error)
{ {