[IMP] core: Deprecate cr.autocommit(True)

Since Odoo 13.0 and the refactor of the internal synchronisation between
the cache and the database, it is unsafe to use the ORM with the cursor
in autocommit mode. The function is deprecated for removal in the
future.

closes odoo/odoo#68313

Task: 2442905
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Julien Castiaux
2021-03-26 16:10:12 +00:00
committed by Raphael Collet
parent 19f21e364e
commit 7a235c19ff
+5
View File
@@ -398,6 +398,11 @@ class Cursor(BaseCursor):
@check
def autocommit(self, on):
if on:
warnings.warn(
"Since Odoo 13.0, the ORM delays UPDATE queries for "
"performance reasons. Since then, using the ORM with "
" autocommit(True) is unsafe, as computed fields may not be "
"fully computed at commit.", DeprecationWarning, stacklevel=2)
isolation_level = ISOLATION_LEVEL_AUTOCOMMIT
else:
# If a serializable cursor was requested, we