[REVERT] unreviewed audittrail fix in previous rev

bzr revid: odo@openerp.com-20121116104936-t3k4051pe51gqds1
This commit is contained in:
Arnaud Pineux 2012-11-16 11:49:36 +01:00 committed by Olivier Dony
parent 814187d0c0
commit fb1c81a9d3
1 changed files with 9 additions and 16 deletions

View File

@ -303,7 +303,7 @@ class audittrail_objects_proxy(object_proxy):
self.process_data(cr, uid_orig, pool, res_ids, model, method, old_values, new_values, field_list)
return res
def get_data(self, cr, uid, pool, res_ids, model, method, parent=None):
def get_data(self, cr, uid, pool, res_ids, model, method):
"""
This function simply read all the fields of the given res_ids, and also recurisvely on
all records of a x2m fields read that need to be logged. Then it returns the result in
@ -351,13 +351,12 @@ class audittrail_objects_proxy(object_proxy):
# we need to remove current resource_id from the many2many to prevent an infinit loop
if resource_id in field_resource_ids:
field_resource_ids.remove(resource_id)
#data.update(self.get_data(cr, SUPERUSER_ID, pool, field_resource_ids, x2m_model, method))
if not parent in [x2m_model.model, model.model] and resource[field]:
data.update(self.get_data(cr, SUPERUSER_ID, pool, resource[field], x2m_model, method, parent=model.model))
data.update(self.get_data(cr, SUPERUSER_ID, pool, field_resource_ids, x2m_model, method))
data[(model.id, resource_id)] = {'text':values_text, 'value': values}
return data
def prepare_audittrail_log_line(self, cr, uid, pool, model, resource_id, method, old_values, new_values, field_list=None, parent=None):
def prepare_audittrail_log_line(self, cr, uid, pool, model, resource_id, method, old_values, new_values, field_list=None):
"""
This function compares the old data (i.e before the method was executed) and the new data
(after the method was executed) and returns a structure with all the needed information to
@ -418,11 +417,8 @@ class audittrail_objects_proxy(object_proxy):
# we need to remove current resource_id from the many2many to prevent an infinit loop
if resource_id in res_ids:
res_ids.remove(resource_id)
#for res_id in res_ids:
# lines.update(self.prepare_audittrail_log_line(cr, SUPERUSER_ID, pool, x2m_model, res_id, method, old_values, new_values, field_list))
if not parent in [x2m_model.model, model.model] and res_ids:
for res_id in res_ids:
lines.update(self.prepare_audittrail_log_line(cr, SUPERUSER_ID, pool, x2m_model, res_id, method, old_values, new_values, field_list, parent=model.model))
for res_id in res_ids:
lines.update(self.prepare_audittrail_log_line(cr, SUPERUSER_ID, pool, x2m_model, res_id, method, old_values, new_values, field_list))
# if the value value is different than the old value: record the change
if key not in old_values or key not in new_values or old_values[key]['value'][field_name] != new_values[key]['value'][field_name]:
data = {
@ -463,9 +459,7 @@ class audittrail_objects_proxy(object_proxy):
# if at least one modification has been found
for model_id, resource_id in lines:
objmodel = pool.get('ir.model').browse(cr, uid, model_id)
name = pool.get(objmodel.model).name_get(cr, uid, [resource_id])[0][1]
#name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1]
name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1]
vals = {
'method': method,
'object_id': model_id,
@ -486,9 +480,8 @@ class audittrail_objects_proxy(object_proxy):
# create the audittrail log in super admin mode, only if a change has been detected
if lines[(model_id, resource_id)]:
log_id = pool.get('audittrail.log').create(cr, SUPERUSER_ID, vals)
self.create_log_line(cr, SUPERUSER_ID, log_id, objmodel, lines[(model_id, resource_id)])
#model = pool.get('ir.model').browse(cr, uid, model_id)
#self.create_log_line(cr, SUPERUSER_ID, log_id, model, lines[(model_id, resource_id)])
model = pool.get('ir.model').browse(cr, uid, model_id)
self.create_log_line(cr, SUPERUSER_ID, log_id, model, lines[(model_id, resource_id)])
return True
def check_rules(self, cr, uid, model, method):