diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 7745d05d71a..97075ddd440 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -638,8 +638,8 @@ class Mo extends CommonObject $oldQty = $this->oldQty; $newQty = $this->qty; - if($newQty != $oldQty) { - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'mrp_production WHERE fk_mo = ' . $this->id; + if($newQty != $oldQty && !empty($this->oldQty)) { + $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'mrp_production WHERE fk_mo = ' . (int) $this->id; $resql = $this->db->query($sql); if($resql) { while ($obj = $this->db->fetch_object($resql)) {