Kuldeep Joshi(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-1012931-kjo into
lp:openobject-addons.
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-dev/openobject-addons/trunk-bug-1012931-kjo/+merge/111222
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1012931-kjo/+merge/111222
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-1012931-kjo.
=== modified file 'audittrail/audittrail.py'
--- audittrail/audittrail.py 2012-05-04 11:57:48 +0000
+++ audittrail/audittrail.py 2012-06-20 13:24:21 +0000
@@ -188,18 +188,20 @@
:param recursive: True or False, True will repeat the process recursively
: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=[]):
"""
@@ -333,18 +335,20 @@
values[field] = resource[field]
# 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
@@ -404,6 +408,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,
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp