[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#60115

X-original-commit: 1d21924c1da0bed59cd105a3d9bf9b60fa2d7bc4
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
This commit is contained in:
Adrian Torres
2020-10-15 15:05:00 +00:00
parent bc4e06106d
commit ece40d83fb
+16
View File
@@ -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