upgrade-registry-clear-cache (U2022)#

registry.clear_cache(), removed in Odoo 20.0.

Applies to Odoo 20.0 and later.

What it does#

Reports registry.clear_cache(...), pool.clear_cache(...) and clear_all_caches().

Why is this bad?#

Odoo 20.0 moved the ormcache to the transaction: the call raises AttributeError. Use env.transaction.invalidate_ormcache(name).

Fix safety#

Safe with at most one cache name, as Odoo’s script 19.4-00-ormcache-on-transaction does: x.env.registry.clear_cache(n) becomes x.env.transaction.invalidate_ormcache(n), and x.pool.clear_cache(n) x.env.transaction.invalidate_ormcache(n). Several names need one call each.