summaryrefslogtreecommitdiff
path: root/odoo/api.py
diff options
context:
space:
mode:
authorbatuto <mariano@vauxoo.com>2017-07-21 15:18:12 -0500
committerMartin Trigaux <mat@odoo.com>2017-08-22 15:46:48 +0200
commitfeef39aee083294f8c8d19aecef0434af04c48d0 (patch)
tree11107dfa4773bc39afe7e9a641e28560fc945235 /odoo/api.py
parent8a4a232e54f6414822e3779a2ea6bc3b9cbebf66 (diff)
[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
Diffstat (limited to 'odoo/api.py')
-rw-r--r--odoo/api.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/odoo/api.py b/odoo/api.py
index 1adbd08f6e5..413a6b8a2a5 100644
--- a/odoo/api.py
+++ b/odoo/api.py
@@ -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)