[FIX] don't reset caches in register_hook

pull/2268/head
Holger Brunn 2015-01-29 15:38:29 +01:00 committed by BT-vgabor
parent 5a89e41207
commit ef0eda9b3c
1 changed files with 5 additions and 2 deletions

View File

@ -111,6 +111,10 @@ class auditlog_rule(models.Model):
def _register_hook(self, cr, ids=None):
"""Get all rules and apply them to log method calls."""
super(auditlog_rule, self)._register_hook(cr)
if not hasattr(self.pool, '_auditlog_field_cache'):
self.pool._auditlog_field_cache = {}
if not hasattr(self.pool, '_auditlog_model_cache'):
self.pool._auditlog_model_cache = {}
if ids is None:
ids = self.search(cr, SUPERUSER_ID, [('state', '=', 'subscribed')])
return self._patch_methods(cr, SUPERUSER_ID, ids)
@ -119,8 +123,7 @@ class auditlog_rule(models.Model):
def _patch_methods(self):
"""Patch ORM methods of models defined in rules to log their calls."""
updated = False
self.pool._auditlog_field_cache = {}
model_cache = self.pool._auditlog_model_cache = {}
model_cache = self.pool._auditlog_model_cache
for rule in self:
if rule.state != 'subscribed':
continue