Merge lp:~openerp-dev/openobject-addons/7.0-opw-599830-fka into lp:openobject-addons/7.0

Proposed by Foram Katharotiya (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-599830-fka
Merge into: lp:openobject-addons/7.0
Diff against target: 47 lines (+6/-3)
1 file modified
audittrail/audittrail.py (+6/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-599830-fka
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+194785@code.launchpad.net

Description of the change

Hello,

I have fixed the issue of traceback:AttributeError: 'Field name not found in browse_record(res.partner, 4934)'

Steps to reproduce:
1) Install audittrail module.
2) Subscribe the customer audit rule from Reporting-> Audit-> Audit rules.
3) Goto customer & delete customer

Thanks,
FKA

To post a comment you must log in.
Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

Hi,

I think this fix is not correct because it will result in giving wrong value for "Resource Name"(for the relational fields of the model) in the created log if followed the above process.

The fix from the branch lp:~openerp-dev/openobject-addons/7.0-opw-589931-rgo should solve this issue.

Thanks.

Unmerged revisions

9548. By Foram Katharotiya (OpenERP)

[MERGE] with 7.0

9547. By Foram Katharotiya (OpenERP)

[FIX] genrate traceback from audittrail module while trying to delete customer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'audittrail/audittrail.py'
--- audittrail/audittrail.py 2012-12-17 15:46:28 +0000
+++ audittrail/audittrail.py 2013-11-12 05:13:58 +0000
@@ -263,6 +263,7 @@
263 # fields to log. currently only used by log on read()263 # fields to log. currently only used by log on read()
264 field_list = []264 field_list = []
265 old_values = new_values = {}265 old_values = new_values = {}
266 name = ''
266267
267 if method == 'create':268 if method == 'create':
268 res = fct_src(cr, uid_orig, model.model, method, *args, **kw)269 res = fct_src(cr, uid_orig, model.model, method, *args, **kw)
@@ -281,6 +282,7 @@
281 field_list = args[1]282 field_list = args[1]
282 elif method == 'unlink':283 elif method == 'unlink':
283 res_ids = args[0]284 res_ids = args[0]
285 name = pool.get(model.model).name_get(cr, uid_orig, res_ids)[0][1]
284 old_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)286 old_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)
285 res = fct_src(cr, uid_orig, model.model, method, *args, **kw)287 res = fct_src(cr, uid_orig, model.model, method, *args, **kw)
286 else: # method is write, action or workflow action288 else: # method is write, action or workflow action
@@ -300,7 +302,7 @@
300 # check the new values and store them into a dictionary302 # check the new values and store them into a dictionary
301 new_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)303 new_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)
302 # compare the old and new values and create audittrail log if needed304 # compare the old and new values and create audittrail log if needed
303 self.process_data(cr, uid_orig, pool, res_ids, model, method, old_values, new_values, field_list)305 self.process_data(cr, uid_orig, pool, res_ids, model, method, name, old_values, new_values, field_list)
304 return res306 return res
305307
306 def get_data(self, cr, uid, pool, res_ids, model, method):308 def get_data(self, cr, uid, pool, res_ids, model, method):
@@ -431,7 +433,7 @@
431 lines[key].append(data)433 lines[key].append(data)
432 return lines434 return lines
433435
434 def process_data(self, cr, uid, pool, res_ids, model, method, old_values=None, new_values=None, field_list=None):436 def process_data(self, cr, uid, pool, res_ids, model, method, name, old_values=None, new_values=None, field_list=None):
435 """437 """
436 This function processes and iterates recursively to log the difference between the old438 This function processes and iterates recursively to log the difference between the old
437 data (i.e before the method was executed) and the new data and creates audittrail log439 data (i.e before the method was executed) and the new data and creates audittrail log
@@ -459,7 +461,8 @@
459461
460 # if at least one modification has been found462 # if at least one modification has been found
461 for model_id, resource_id in lines:463 for model_id, resource_id in lines:
462 name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1]464 if not name:
465 name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1]
463 vals = {466 vals = {
464 'method': method,467 'method': method,
465 'object_id': model_id,468 'object_id': model_id,