Delete from product_batch on product delete
This commit is contained in:
parent
59ba5ef484
commit
2e6b27f094
@ -924,7 +924,23 @@ class Product extends CommonObject
|
|||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete from product_batch on product delete
|
||||||
|
if (! $error && $this->hasbatch())
|
||||||
|
{
|
||||||
|
$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)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user