[FIX]audittrail:on deletion of record from one2many and saving the parent form error...
authorSomesh Khare (OpenERP) <skh@openerp.com>
Wed, 12 Mar 2014 05:45:35 +0000 (11:15 +0530)
committerSomesh Khare (OpenERP) <skh@openerp.com>
Wed, 12 Mar 2014 05:45:35 +0000 (11:15 +0530)
bzr revid: skh@openerp.com-20140312054535-kjlqltscnojb7lce

addons/audittrail/audittrail.py

index 63b505e..b68a8e2 100644 (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)