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
1=== modified file 'audittrail/audittrail.py'
2--- audittrail/audittrail.py 2012-12-17 15:46:28 +0000
3+++ audittrail/audittrail.py 2013-11-12 05:13:58 +0000
4@@ -263,6 +263,7 @@
5 # fields to log. currently only used by log on read()
6 field_list = []
7 old_values = new_values = {}
8+ name = ''
9
10 if method == 'create':
11 res = fct_src(cr, uid_orig, model.model, method, *args, **kw)
12@@ -281,6 +282,7 @@
13 field_list = args[1]
14 elif method == 'unlink':
15 res_ids = args[0]
16+ name = pool.get(model.model).name_get(cr, uid_orig, res_ids)[0][1]
17 old_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)
18 res = fct_src(cr, uid_orig, model.model, method, *args, **kw)
19 else: # method is write, action or workflow action
20@@ -300,7 +302,7 @@
21 # check the new values and store them into a dictionary
22 new_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)
23 # compare the old and new values and create audittrail log if needed
24- self.process_data(cr, uid_orig, pool, res_ids, model, method, old_values, new_values, field_list)
25+ self.process_data(cr, uid_orig, pool, res_ids, model, method, name, old_values, new_values, field_list)
26 return res
27
28 def get_data(self, cr, uid, pool, res_ids, model, method):
29@@ -431,7 +433,7 @@
30 lines[key].append(data)
31 return lines
32
33- def process_data(self, cr, uid, pool, res_ids, model, method, old_values=None, new_values=None, field_list=None):
34+ def process_data(self, cr, uid, pool, res_ids, model, method, name, old_values=None, new_values=None, field_list=None):
35 """
36 This function processes and iterates recursively to log the difference between the old
37 data (i.e before the method was executed) and the new data and creates audittrail log
38@@ -459,7 +461,8 @@
39
40 # if at least one modification has been found
41 for model_id, resource_id in lines:
42- name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1]
43+ if not name:
44+ name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1]
45 vals = {
46 'method': method,
47 'object_id': model_id,