auditlog - Migrate 'AuditlogRule.create' and 'AuditlogRule.write' methods to the new API

pull/2755/head
sebalix 2016-11-14 15:12:24 +01:00 committed by Raf Ven
parent 587928146c
commit 25a9ab8f25
1 changed files with 13 additions and 16 deletions

View File

@ -171,25 +171,22 @@ class AuditlogRule(models.Model):
modules.registry.RegistryManager.signal_registry_change( modules.registry.RegistryManager.signal_registry_change(
self.env.cr.dbname) self.env.cr.dbname)
# Unable to find a way to declare the `create` method with the new API, @api.model
# errors occurs with the `_register_hook()` BaseModel method. def create(self, vals):
def create(self, cr, uid, vals, context=None):
"""Update the registry when a new rule is created.""" """Update the registry when a new rule is created."""
res_id = super(AuditlogRule, self).create( new_record = super(AuditlogRule, self).create(vals)
cr, uid, vals, context=context) if self._model._register_hook(self.env.cr, new_record.ids):
if self._register_hook(cr, [res_id]): modules.registry.RegistryManager.signal_registry_change(
modules.registry.RegistryManager.signal_registry_change(cr.dbname) self.env.cr.dbname)
return res_id return new_record
# Unable to find a way to declare the `write` method with the new API, @api.multi
# errors occurs with the `_register_hook()` BaseModel method. def write(self, vals):
def write(self, cr, uid, ids, vals, context=None):
"""Update the registry when existing rules are updated.""" """Update the registry when existing rules are updated."""
if isinstance(ids, (int, long)): super(AuditlogRule, self).write(vals)
ids = [ids] if self._model._register_hook(self.env.cr, self.ids):
super(AuditlogRule, self).write(cr, uid, ids, vals, context=context) modules.registry.RegistryManager.signal_registry_change(
if self._register_hook(cr, ids): self.env.cr.dbname)
modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return True return True
@api.multi @api.multi