[MERGE] Avoid some unnecessary ormcache invalidations
Avoid invalidating ormcache when possible. There are currently too many invalidations, which makes the ormcache less effective in practice. closes odoo/odoo#28993
This commit is contained in:
@@ -885,6 +885,8 @@ class Import(models.TransientModel):
|
||||
try:
|
||||
if dryrun:
|
||||
self._cr.execute('ROLLBACK TO SAVEPOINT import')
|
||||
# cancel all changes done to the registry/ormcache
|
||||
self.pool.reset_changes()
|
||||
else:
|
||||
self._cr.execute('RELEASE SAVEPOINT import')
|
||||
except psycopg2.InternalError:
|
||||
|
||||
@@ -83,7 +83,8 @@ class IrConfigParameter(models.Model):
|
||||
if param:
|
||||
old = param.value
|
||||
if value is not False and value is not None:
|
||||
param.write({'value': value})
|
||||
if str(value) != old:
|
||||
param.write({'value': value})
|
||||
else:
|
||||
param.unlink()
|
||||
return old
|
||||
|
||||
+2
-1
@@ -846,7 +846,6 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
ids = []
|
||||
messages = []
|
||||
ModelData = self.env['ir.model.data']
|
||||
ModelData.clear_caches()
|
||||
|
||||
# list of (xid, vals, info) for records to be created in batch
|
||||
batch = []
|
||||
@@ -928,6 +927,8 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
if any(message['type'] == 'error' for message in messages):
|
||||
cr.execute('ROLLBACK TO SAVEPOINT model_load')
|
||||
ids = False
|
||||
# cancel all changes done to the registry/ormcache
|
||||
self.pool.reset_changes()
|
||||
|
||||
return {'ids': ids, 'messages': messages}
|
||||
|
||||
|
||||
@@ -151,8 +151,6 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
|
||||
module_count = len(graph)
|
||||
_logger.info('loading %d modules...', module_count)
|
||||
|
||||
registry.clear_caches()
|
||||
|
||||
# register, instantiate and initialize models for each modules
|
||||
t0 = time.time()
|
||||
t0_sql = odoo.sql_db.sql_counter
|
||||
@@ -278,9 +276,6 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
|
||||
|
||||
_logger.log(25, "%s modules loaded in %.2fs, %s queries", len(graph), time.time() - t0, odoo.sql_db.sql_counter - t0_sql)
|
||||
|
||||
registry.clear_caches()
|
||||
|
||||
|
||||
return loaded_modules, processed_modules
|
||||
|
||||
def _check_module_names(cr, module_names):
|
||||
|
||||
Reference in New Issue
Block a user