openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #01248
[Merge] lp:~openerp-community/openobject-addons/6.1-bug-1012931 into lp:openobject-addons/6.1
Maxime Chambreuil (http://www.savoirfairelinux.com) has proposed merging lp:~openerp-community/openobject-addons/6.1-bug-1012931 into lp:openobject-addons/6.1.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #1012931 in OpenERP Addons: "audit trail one2many error"
https://bugs.launchpad.net/openobject-addons/+bug/1012931
For more details, see:
https://code.launchpad.net/~openerp-community/openobject-addons/6.1-bug-1012931/+merge/122604
[FIX] Audittrail
--
https://code.launchpad.net/~openerp-community/openobject-addons/6.1-bug-1012931/+merge/122604
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openobject-addons/6.1-bug-1012931.
=== modified file 'audittrail/audittrail.py'
--- audittrail/audittrail.py 2012-03-23 14:25:41 +0000
+++ audittrail/audittrail.py 2012-09-04 00:06:20 +0000
@@ -189,17 +189,20 @@
:return: string value or a list of values(for O2M/M2M)
"""
- field_obj = (resource_pool._all_columns.get(field)).column
- if field_obj._type in ('one2many','many2many'):
- data = pool.get(field_obj._obj).name_get(cr, uid, value)
- #return the modifications on x2many fields as a list of names
- res = map(lambda x:x[1], data)
- elif field_obj._type == 'many2one':
- #return the modifications on a many2one field as its value returned by name_get()
- res = value and value[1] or value
+ if field not in resource_pool._all_columns.keys():
+ return value
else:
- res = value
- return res
+ field_obj = (resource_pool._all_columns.get(field)).column
+ if field_obj._type in ('one2many','many2many'):
+ data = pool.get(field_obj._obj).name_get(cr, uid, value)
+ #return the modifications on x2many fields as a list of names
+ res = map(lambda x:x[1], data)
+ elif field_obj._type == 'many2one':
+ #return the modifications on a many2one field as its value returned by name_get()
+ res = value and value[1] or value
+ else:
+ res = value
+ return res
def create_log_line(self, cr, uid, log_id, model, lines=[]):
"""
@@ -334,17 +337,20 @@
# get the textual value of that field for this record
values_text[field] = self.get_value_text(cr, 1, pool, resource_pool, method, field, resource[field])
- field_obj = resource_pool._all_columns.get(field).column
- if field_obj._type in ('one2many','many2many'):
- # check if an audittrail rule apply in super admin mode
- if self.check_rules(cr, 1, field_obj._obj, method):
- # check if the model associated to a *2m field exists, in super admin mode
- x2m_model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', field_obj._obj)])
- x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False
- assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj))
- x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id)
- #recursive call on x2m fields that need to be checked too
- data.update(self.get_data(cr, 1, pool, resource[field], x2m_model, method))
+ if field not in resource_pool._all_columns.keys():
+ pass
+ else:
+ field_obj = resource_pool._all_columns.get(field).column
+ if field_obj._type in ('one2many','many2many'):
+ # check if an audittrail rule apply in super admin mode
+ if self.check_rules(cr, 1, field_obj._obj, method):
+ # check if the model associated to a *2m field exists, in super admin mode
+ x2m_model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', field_obj._obj)])
+ x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False
+ assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj))
+ x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id)
+ #recursive call on x2m fields that need to be checked too
+ data.update(self.get_data(cr, 1, pool, resource[field], x2m_model, method))
data[(model.id, resource_id)] = {'text':values_text, 'value': values}
return data
@@ -405,6 +411,8 @@
for res_id in res_ids:
lines.update(self.prepare_audittrail_log_line(cr, 1, pool, x2m_model, res_id, method, old_values, new_values, field_list))
# if the value value is different than the old value: record the change
+ if field_name == 'id':
+ continue
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]:
data = {
'name': field_name,
Follow ups