From ad065093eb595e0b26dfd6d245e1b598d70e9d87 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 22 Nov 2018 10:59:09 +0000 Subject: [PATCH 1/3] [FIX] models: ormcache invalidation on import Do not propagate cache invalidations to other workers when changes must be discarded, because of an import error or a dry run, which are both handled as successful transactions. --- addons/base_import/models/base_import.py | 2 ++ odoo/models.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py index 35d5692e95b..4e4945fd37c 100644 --- a/addons/base_import/models/base_import.py +++ b/addons/base_import/models/base_import.py @@ -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: diff --git a/odoo/models.py b/odoo/models.py index 1af6cd9c173..b2aab1d5f36 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -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} From e181f592f33b2ae382569927537aed84689ee44f Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 22 Nov 2018 11:00:53 +0000 Subject: [PATCH 2/3] [FIX] odoo: ormcache invalidation on loading registry Do not propagate cache invalidations to other workers when simply loading the registry. Only do it when installing/upgrading/uninstalling modules. --- odoo/modules/loading.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index bc95e1c461d..5fb56887948 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -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): From c96d4cdbadf8d15abcad19e8f5839b46bb025e04 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 23 Nov 2018 14:02:17 +0000 Subject: [PATCH 3/3] [FIX] base: ormcache invalidation in `ir.config.parameter` Writing on a parameter invalidates the ormcache and propagates the invalidation to other workers. Setting a parameter to its current value should not trigger ormcache invalidations. --- odoo/addons/base/models/ir_config_parameter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_config_parameter.py b/odoo/addons/base/models/ir_config_parameter.py index eed10daadd8..b7f2356e803 100644 --- a/odoo/addons/base/models/ir_config_parameter.py +++ b/odoo/addons/base/models/ir_config_parameter.py @@ -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