[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
This commit is contained in:
Martin Trigaux 2014-02-04 15:14:49 +01:00
parent 2bebb9cd4d
commit 45f52a3493
1 changed files with 9 additions and 3 deletions

View File

@ -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,