Generate value custom field

So in Belgium we have a certain value on our invoices, that shows the payment mark.
It looks like this.

+++663/0502/21793+++

it’s a automatic generated number, but now i want to add that to our fields
The problem is, a custom field can’t be un editable and i just can’t get the field filled.

This is the code that will generate the structured message.
And it should be disabled.
Anyone an idea how to fix this ?

function generateRandomOGM($markup = false) {
$randNumber = rand(1000000000, 9999999999);
$rest       = $randNumber % 97;

if ($rest === 0) {
	$rest = 97;
}
if ($rest < 10) {
	$rest = "0" . $rest;
}

$ogm = $randNumber.$rest;
if ($markup) {
	$ogm = "+++".substr($ogm,0,3)."/".substr($ogm,3,4)."/".substr($ogm,7,5)."+++";
}

return $ogm;

}