[FIX]audittrail:on deletion of record from one2many and saving the parent form error raised as list index out of range (Ref: Case 604750)

bzr revid: skh@openerp.com-20140312054535-kjlqltscnojb7lce
This commit is contained in:
Somesh Khare (OpenERP) 2014-03-12 11:15:35 +05:30
parent 160229d58e
commit 6c96d110ab
1 changed files with 4 additions and 2 deletions

View File

@ -466,14 +466,12 @@ class audittrail_objects_proxy(object_proxy):
# if at least one modification has been found
for model_id, resource_id in lines:
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,
'user_id': uid,
'res_id': resource_id,
'name': name,
}
if (model_id, resource_id) not in old_values and method not in ('copy', 'read'):
# the resource was not existing so we are forcing the method to 'create'
@ -484,7 +482,11 @@ class audittrail_objects_proxy(object_proxy):
# the resource is not existing anymore so we are forcing the method to 'unlink'
# (because it could also come with the value 'write' if we are deleting the
# record through a one2many field)
name = old_values[(model_id, resource_id)]['value'].get('name',False)
vals.update({'method': 'unlink'})
else :
name = pool[line_model].name_get(cr, uid, [resource_id])[0][1]
vals.update({'name': name})
# 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)