[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:
parent
2bebb9cd4d
commit
45f52a3493
|
@ -271,10 +271,14 @@ class audittrail_objects_proxy(object_proxy):
|
||||||
new_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)
|
new_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)
|
||||||
elif method == 'read':
|
elif method == 'read':
|
||||||
res = fct_src(cr, uid_orig, model.model, method, *args, **kw)
|
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
|
# build the res_ids and the old_values dict. Here we don't use get_data() to
|
||||||
# avoid performing an additional read()
|
# avoid performing an additional read()
|
||||||
res_ids = []
|
res_ids = []
|
||||||
for record in res:
|
for record in records:
|
||||||
res_ids.append(record['id'])
|
res_ids.append(record['id'])
|
||||||
old_values[(model.id, record['id'])] = {'value': record, 'text': record}
|
old_values[(model.id, record['id'])] = {'value': record, 'text': record}
|
||||||
# log only the fields read
|
# log only the fields read
|
||||||
|
@ -325,7 +329,7 @@ class audittrail_objects_proxy(object_proxy):
|
||||||
data = {}
|
data = {}
|
||||||
resource_pool = pool.get(model.model)
|
resource_pool = pool.get(model.model)
|
||||||
# read all the fields of the given resources in super admin mode
|
# 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 = {}
|
||||||
values_text = {}
|
values_text = {}
|
||||||
resource_id = resource['id']
|
resource_id = resource['id']
|
||||||
|
@ -459,7 +463,9 @@ class audittrail_objects_proxy(object_proxy):
|
||||||
|
|
||||||
# if at least one modification has been found
|
# if at least one modification has been found
|
||||||
for model_id, resource_id in lines:
|
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 = {
|
vals = {
|
||||||
'method': method,
|
'method': method,
|
||||||
'object_id': model_id,
|
'object_id': model_id,
|
||||||
|
|
Loading…
Reference in New Issue