Merge lp:~openerp-community/openobject-addons/6.1-bug-1012931 into lp:openobject-addons/6.1

Status: Needs review
Proposed branch: lp:~openerp-community/openobject-addons/6.1-bug-1012931
Merge into: lp:openobject-addons/6.1
Diff against target: 75 lines (+29/-21)
1 file modified
audittrail/audittrail.py (+29/-21)
To merge this branch: bzr merge lp:~openerp-community/openobject-addons/6.1-bug-1012931
Reviewer Review Type Date Requested Status
Leonardo Pistone (community) test for bug 1157497, code review Approve
OpenERP Core Team Pending
Review via email: mp+122604@code.launchpad.net

Description of the change

[FIX] Audittrail

To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Hi Maxime,
This old MP in my opinion fixes bug #1157497 just fine. The 6.1 patch supplied there, in my opinion, doesn't.
I can propose that for OCB as well, do you agree?

Thanks!

review: Approve (test for bug 1157497, code review)
Revision history for this message
debaetsr (rubendebaets) wrote :

Hello,

I've got some news for you, I'm so excited that I couldn't fall asleep last night. Read it here please <http://option.phuspicks.com/e4msb>

Yours truly, ruben

Unmerged revisions

6974. By Kuldeep Joshi(OpenERP)

[FIX] audittrail: check field in column or not

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-03-23 14:25:41 +0000
3+++ audittrail/audittrail.py 2012-09-04 00:06:20 +0000
4@@ -189,17 +189,20 @@
5 :return: string value or a list of values(for O2M/M2M)
6 """
7
8- field_obj = (resource_pool._all_columns.get(field)).column
9- if field_obj._type in ('one2many','many2many'):
10- data = pool.get(field_obj._obj).name_get(cr, uid, value)
11- #return the modifications on x2many fields as a list of names
12- res = map(lambda x:x[1], data)
13- elif field_obj._type == 'many2one':
14- #return the modifications on a many2one field as its value returned by name_get()
15- res = value and value[1] or value
16+ if field not in resource_pool._all_columns.keys():
17+ return value
18 else:
19- res = value
20- return res
21+ field_obj = (resource_pool._all_columns.get(field)).column
22+ if field_obj._type in ('one2many','many2many'):
23+ data = pool.get(field_obj._obj).name_get(cr, uid, value)
24+ #return the modifications on x2many fields as a list of names
25+ res = map(lambda x:x[1], data)
26+ elif field_obj._type == 'many2one':
27+ #return the modifications on a many2one field as its value returned by name_get()
28+ res = value and value[1] or value
29+ else:
30+ res = value
31+ return res
32
33 def create_log_line(self, cr, uid, log_id, model, lines=[]):
34 """
35@@ -334,17 +337,20 @@
36 # get the textual value of that field for this record
37 values_text[field] = self.get_value_text(cr, 1, pool, resource_pool, method, field, resource[field])
38
39- field_obj = resource_pool._all_columns.get(field).column
40- if field_obj._type in ('one2many','many2many'):
41- # check if an audittrail rule apply in super admin mode
42- if self.check_rules(cr, 1, field_obj._obj, method):
43- # check if the model associated to a *2m field exists, in super admin mode
44- x2m_model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', field_obj._obj)])
45- x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False
46- assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj))
47- x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id)
48- #recursive call on x2m fields that need to be checked too
49- data.update(self.get_data(cr, 1, pool, resource[field], x2m_model, method))
50+ if field not in resource_pool._all_columns.keys():
51+ pass
52+ else:
53+ field_obj = resource_pool._all_columns.get(field).column
54+ if field_obj._type in ('one2many','many2many'):
55+ # check if an audittrail rule apply in super admin mode
56+ if self.check_rules(cr, 1, field_obj._obj, method):
57+ # check if the model associated to a *2m field exists, in super admin mode
58+ x2m_model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', field_obj._obj)])
59+ x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False
60+ assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj))
61+ x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id)
62+ #recursive call on x2m fields that need to be checked too
63+ data.update(self.get_data(cr, 1, pool, resource[field], x2m_model, method))
64 data[(model.id, resource_id)] = {'text':values_text, 'value': values}
65 return data
66
67@@ -405,6 +411,8 @@
68 for res_id in res_ids:
69 lines.update(self.prepare_audittrail_log_line(cr, 1, pool, x2m_model, res_id, method, old_values, new_values, field_list))
70 # if the value value is different than the old value: record the change
71+ if field_name == 'id':
72+ continue
73 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]:
74 data = {
75 'name': field_name,