From fe36ce99880dc9bbfacd492a5bd65cbd8e665675 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 28 Jan 2015 15:06:44 +0100 Subject: [PATCH 1/2] [IMP] ignore rules for nonexisting objects --- auditlog/models/rule.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auditlog/models/rule.py b/auditlog/models/rule.py index 338eb7f47..56c8ebc5c 100644 --- a/auditlog/models/rule.py +++ b/auditlog/models/rule.py @@ -123,6 +123,9 @@ class auditlog_rule(models.Model): for rule in self: if rule.state != 'subscribed': continue + if not self.pool.get(rule.model_id.model): + # ignore rules for models not loadable currently + continue model_model = self.env[rule.model_id.model] # CRUD # -> create From 1f05b1235ccd2d54391562ad314d23a25e30554a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 28 Jan 2015 15:06:29 +0100 Subject: [PATCH 2/2] [ADD] init hook to migrate from audittrail --- auditlog/__init__.py | 14 ++++++++++++++ auditlog/__openerp__.py | 1 + 2 files changed, 15 insertions(+) diff --git a/auditlog/__init__.py b/auditlog/__init__.py index 81ad0d90e..15e9ca739 100644 --- a/auditlog/__init__.py +++ b/auditlog/__init__.py @@ -20,3 +20,17 @@ ############################################################################## from . import models + + +def pre_init_hook(cr): + cr.execute("SELECT 1 FROM pg_class WHERE relname = 'audittrail_rule'") + if cr.fetchall(): + migrate_from_audittrail(cr) + + +def migrate_from_audittrail(cr): + cr.execute('ALTER TABLE audittrail_rule RENAME TO auditlog_rule') + cr.execute('ALTER TABLE auditlog_rule RENAME COLUMN object_id TO model_id') + cr.execute('ALTER TABLE audittrail_log RENAME TO auditlog_log') + cr.execute('ALTER TABLE auditlog_log RENAME COLUMN object_id TO model_id') + cr.execute('ALTER TABLE audittrail_log_line RENAME TO auditlog_log_line') diff --git a/auditlog/__openerp__.py b/auditlog/__openerp__.py index 8283c36dc..ecfe0a28f 100644 --- a/auditlog/__openerp__.py +++ b/auditlog/__openerp__.py @@ -35,4 +35,5 @@ 'application': True, 'installable': True, 'active': False, + 'pre_init_hook': 'pre_init_hook', }