Only set Ticket ref if not yet present via import or synchro (#82)

New non blocking uniqueness rule on Ticket.ref to warn when having ref duplicates
This commit is contained in:
Thomas Casteleyn
2019-06-10 11:28:24 +02:00
committed by Pierre Goiffon
parent ecd8f40c0f
commit daa906a697

View File

@@ -53,6 +53,14 @@
</attributes>
</index>
</indexes>
<uniqueness_rules>
<rule if="ref">
<attributes>
<attribute id="ref"/>
</attributes>
<is_blocking>false</is_blocking>
</rule>
</uniqueness_rules>
</properties>
<fields>
<field id="operational_status" xsi:type="AttributeMetaEnum">
@@ -209,7 +217,7 @@
$oMutex->Lock();
$iNextId = MetaModel::GetNextKey(get_class($this));
$sRef = $this->MakeTicketRef($iNextId);
$this->Set('ref', $sRef);
$this->SetIfNull('ref', $sRef);
$iKey = parent::DBInsertNoReload();
$oMutex->Unlock();
return $iKey;