N°3495 WorkOrder: on closure set end_date only if empty

This commit is contained in:
vdumas
2021-02-12 11:05:39 +01:00
parent c8dd19c22f
commit a8c834b1e9
3 changed files with 41 additions and 1 deletions

View File

@@ -3982,6 +3982,30 @@ abstract class DBObject implements iDisplay
return true;
}
/**
* Helper to set a value only if it is currently undefined
*
* Call SetCurrentDate() only of the internal representation of the attribute is null.
*
* @api
* @see SetCurrentDate()
*
* @param string $sAttCode
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @since 3.0.0
*/
public function SetCurrentDateIfNull($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
$oCurrentValue = $this->Get($sAttCode);
if ($oAttDef->IsNull($oCurrentValue))
{
$this->SetCurrentDate($sAttCode);
}
}
/**
* Helper to set the current logged in user for the given attribute
* Suitable for use as a lifecycle action