From 45f52a34932ca49a30fab6bfedacf54a8bab3b26 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 4 Feb 2014 15:14:49 +0100 Subject: [PATCH] [FIX] audittrail: fixing various bugs iter only on fields on __all_columns, this avoids getting inexistant fields such as 'in_group_42' for res.users make sure read method calls works when passing only one id (lp:1214149) when itering on change values, if different model (eg: if field is o2m) make sure make name_get on the model of the field and not on the parent model lp bug: https://launchpad.net/bugs/1214149 fixed bzr revid: mat@openerp.com-20140204141449-2f922k5awixh1kzt --- addons/audittrail/audittrail.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 7364ea505f6..0de34f4b69d 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -271,10 +271,14 @@ class audittrail_objects_proxy(object_proxy): new_values = self.get_data(cr, uid_orig, pool, res_ids, model, method) elif method == 'read': res = fct_src(cr, uid_orig, model.model, method, *args, **kw) + if isinstance(res, dict): + records = [res] + else: + records = res # build the res_ids and the old_values dict. Here we don't use get_data() to # avoid performing an additional read() res_ids = [] - for record in res: + for record in records: res_ids.append(record['id']) old_values[(model.id, record['id'])] = {'value': record, 'text': record} # log only the fields read @@ -325,7 +329,7 @@ class audittrail_objects_proxy(object_proxy): data = {} resource_pool = pool.get(model.model) # read all the fields of the given resources in super admin mode - for resource in resource_pool.read(cr, SUPERUSER_ID, res_ids): + for resource in resource_pool.read(cr, SUPERUSER_ID, res_ids, resource_pool._all_columns): values = {} values_text = {} resource_id = resource['id'] @@ -459,7 +463,9 @@ class audittrail_objects_proxy(object_proxy): # if at least one modification has been found for model_id, resource_id in lines: - name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1] + line_model = pool.get('ir.model').browse(cr, SUPERUSER_ID, model_id).model + name = pool.get(line_model).name_get(cr, uid, [resource_id])[0][1] + vals = { 'method': method, 'object_id': model_id,