diff --git a/auditlog/models/rule.py b/auditlog/models/rule.py index 7e58579a4..9549a7d5b 100644 --- a/auditlog/models/rule.py +++ b/auditlog/models/rule.py @@ -219,10 +219,9 @@ class auditlog_rule(models.Model): def read(self, *args, **kwargs): result = read.origin(self, *args, **kwargs) # Sometimes the result is not a list but a dictionary - try: - read_values = dict((d['id'], d) for d in result) - except TypeError: - read_values = dict((d['id'], d) for d in [result]) + if not isinstance(result, list): + result = [result] + read_values = dict((d['id'], d) for d in result) # Old API if args and isinstance(args[0], sql_db.Cursor): cr, uid, ids = args[0], args[1], args[2] @@ -318,8 +317,7 @@ class auditlog_rule(models.Model): # - search the field in the current model and those it inherits field_model = self.env['ir.model.fields'] all_model_ids = [model.id] - all_model_ids.extend( - inherited.id for inherited in model.inherited_model_ids) + all_model_ids.extend(model.inherited_model_ids.ids) field = field_model.search( [('model_id', 'in', all_model_ids), ('name', '=', field_name)]) # The field can be a dummy one, like 'in_group_X' on 'res.users' diff --git a/auditlog/tests/test_auditlog.py b/auditlog/tests/test_auditlog.py index c288184f1..ae1e7b751 100644 --- a/auditlog/tests/test_auditlog.py +++ b/auditlog/tests/test_auditlog.py @@ -96,7 +96,9 @@ class TestAuditlog(TransactionCase): user = self.env['res.users'].create({ 'name': 'testuser_inheritedfield', 'login': 'testuser.inheritedfield@company.com', - 'lang': 'en_US', # field inherited from 'res.partner' + # fields inherited from 'res.partner' + 'lang': 'en_US', + 'notify_email': 'none', }) self.assertTrue(auditlog_log.search([ ('model_id', '=', users_model_id),