Browse Source

Merge pull request #1 from hbrunn/8.0-auditlog

migration from audittrail, small precaution
pull/119/head
Sébastien Alix 10 years ago
parent
commit
e78fbb7cee
  1. 14
      auditlog/__init__.py
  2. 1
      auditlog/__openerp__.py
  3. 3
      auditlog/models/rule.py

14
auditlog/__init__.py

@ -20,3 +20,17 @@
############################################################################## ##############################################################################
from . import models 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')

1
auditlog/__openerp__.py

@ -35,4 +35,5 @@
'application': True, 'application': True,
'installable': True, 'installable': True,
'active': False, 'active': False,
'pre_init_hook': 'pre_init_hook',
} }

3
auditlog/models/rule.py

@ -123,6 +123,9 @@ class auditlog_rule(models.Model):
for rule in self: for rule in self:
if rule.state != 'subscribed': if rule.state != 'subscribed':
continue 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] model_model = self.env[rule.model_id.model]
# CRUD # CRUD
# -> create # -> create

Loading…
Cancel
Save