Domain validation error customization


I would like to ask if there is any way to customize/improve the domain validation error? To make it more concise and human readable.

Thank you.


It is using the same syntax as the search bar (aka the domain parser).
If you can find a better way to express some domain, fill free to propose it.

@ced I once thought of defining a “per field” error message for domain errors, which would then be used in place of the auto-generated one. This would require a way to make it extensible (when a module modifies the domain of an existing field), and having a way to access the current records field values, but I do not see why it would not be possible.

The big issue with such proposal feature is that it will be impossible to guarantee that the error message is providing the correct information that are actually in the domain.

Yes, I agree that this may prove difficult to ensure, that is why I never spent any time on this.

However, I agree with @taiheui0114 that even for some simple domains (like the one he provided as an example), the current approach can be frustrating.

Maybe it could be possible to still provide a “technical explanation” (the current message) by clicking the original, maybe innaccurate message ?

My favorite idea was to add an optionnal entry on each clause, however this risks breaking every searcher… Something like:

clause = ('', '=', Eval('company'), lazy_gettext('msg_account_company_must_match'))

domain = ['OR', clause1, clause2, lazy_gettext('msg_full_domain')]

I really do not see what is not clear in the current message. The Quantity must be greater than 0 and less or equals to 8338.
One possible improvement would be to display: “Quantity: between 0 and 8338”. But then we loose the clarity of the mathematical symbol which define if borders are included or exclude.
Another option would be to use the mathematical segment notation: “Quantity: ]0,8338]”. But I’m not sure it will be clearer to user.

So finally I do not see what extra message could really improve the existing one.

1 Like