From 3a58d5699964a526ee79111ebe790d7a4654e3f6 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 29 Jan 2015 15:38:29 +0100 Subject: [PATCH] [FIX] don't reset caches in register_hook --- auditlog/models/rule.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/auditlog/models/rule.py b/auditlog/models/rule.py index ce00d629d..bcc75b3ba 100644 --- a/auditlog/models/rule.py +++ b/auditlog/models/rule.py @@ -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