[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.
This commit is contained in:
Raphael Collet
2018-11-22 11:03:51 +00:00
parent 9049892152
commit ad065093eb
2 changed files with 4 additions and 1 deletions
+2
View File
@@ -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:
+2 -1
View File
@@ -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}