[IMP] doc: add warning about constrain method trigger

It may be confusing that a constraint is not triggered in a name_create call.
Testing the absence of value should be done in an override of create, not in a
api.constrains.

Closes #18382
This commit is contained in:
batuto
2017-08-22 15:46:48 +02:00
committed by Martin Trigaux
parent 8a4a232e54
commit feef39aee0
+8
View File
@@ -155,6 +155,14 @@ def constrains(*args):
``@constrains`` only supports simple field names, dotted names
(fields of relational fields e.g. ``partner_id.customer``) are not
supported and will be ignored
``@constrains`` will be triggered only if the declared fields in the
decorated method are included in the ``create`` or ``write`` call.
It implies that fields not present in a view will not trigger a call
during a record creation. A override of ``create`` is necessary to make
sure a constraint will always be triggered (e.g. to test the absence of
value).
"""
return attrsetter('_constrains', args)