diff --git a/core/dbobject.class.php b/core/dbobject.class.php index faed30457..9112ecef8 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2986,11 +2986,7 @@ abstract class DBObject implements iDisplay // Ensure the update of the values (we are accessing the data directly) $this->DoComputeValues(); $this->OnInsert(); - if ($this->m_iKey < 0) { - // This was a temporary "memory" key: discard it so that DBInsertSingleTable will not try to use it! - $this->m_iKey = null; - $this->UpdateCurrentObjectInCrudStack(); - } + // If not automatically computed, then check that the key is given by the caller if (!MetaModel::IsAutoIncrementKey($sRootClass)) { if (empty($this->m_iKey)) { @@ -3006,6 +3002,7 @@ abstract class DBObject implements iDisplay if ($this->m_iKey < 0) { // This was a temporary "memory" key: discard it so that DBInsertSingleTable will not try to use it! $this->m_iKey = null; + $this->UpdateCurrentObjectInCrudStack(); } $this->ComputeStopWatchesDeadline(true);