Enforce unique value for invisible field
With #11953 (closed) the enforcement is not done if the field is not required but sometimes the field is not required but invisible. Thus having an invalid value is a problem without #7138 (closed).
Indeed a common pattern for fields that are useless in some states is to set a domain line:
domain=[
If(Eval(...),
('field', '=', None),
()),
]
This ensures that the field is cleared with not usable.