summaryrefslogtreecommitdiff
path: root/doc/reference
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2020-10-14 12:44:26 +0000
committerAdrian Torres <adt@odoo.com>2020-10-15 14:14:14 +0000
commit343ab221569c202d5067913c0d453de40acdbad2 (patch)
tree946451165b89bd89501ce05af76e01a5e7c551e4 /doc/reference
parent544cb3682033e9f644b48b97dd5197eaf9282ff5 (diff)
[FIX] doc: warn about pitfalls of inverse batching
This commit updates the documentation surrounding compute and inverse methods for fields, explicitly warning API consumers that grouping multiple compute fields under a single inverse method is error-prone and could not work at all (it can still work under specific conditions but henceforth it shall be considered bad practice). This case was found at https://github.com/odoo/enterprise/pull/13815/commits/a651413df915f166697d26a83084582207405858 closes odoo/odoo#60103 X-original-commit: 1d21924c1da0bed59cd105a3d9bf9b60fa2d7bc4 Signed-off-by: Raphael Collet (rco) <rco@openerp.com> Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
Diffstat (limited to 'doc/reference')
-rw-r--r--doc/reference/orm.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/reference/orm.rst b/doc/reference/orm.rst
index 7d2b3bd1ac6..3ca49846fb6 100644
--- a/doc/reference/orm.rst
+++ b/doc/reference/orm.rst
@@ -302,6 +302,22 @@ it uses the values of other *fields*, it should specify those fields using
record.discount_value = discount
record.total = record.value - discount
+.. warning::
+
+ While it is possible to use the same compute method for multiple
+ fields, it is not recommended to do the same for the inverse
+ method.
+
+ During the computation of the inverse, **all** fields that use
+ said inverse are protected, meaning that they can't be computed,
+ even if their value is not in the cache.
+
+ If any of those fields is accessed and its value is not in cache,
+ the ORM will simply return a default value of `False` for these fields.
+ This means that the value of the inverse fields (other than the one
+ triggering the inverse method) may not give their correct value and
+ this will probably break the expected behavior of the inverse method.
+
.. _reference/fields/related:
Related fields