Merge lp:~openerp-dev/openobject-addons/6.1-opw-573362-han into lp:openobject-addons/6.1

Proposed by Hardik Ansodariya (OpenERP)
Status: Approved
Approved by: Naresh(OpenERP)
Approved revision: 6738
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-573362-han
Merge into: lp:openobject-addons/6.1
Diff against target: 28 lines (+10/-1)
1 file modified
audittrail/audittrail.py (+10/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-573362-han
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Review via email: mp+103648@code.launchpad.net

Description of the change

Hello,

Fixed the problem of maximum recursion depth when object has many2many field of it self with respect of maintenance case:573362 .

Thanks

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Could this branch be merged in addons/6.1 please ?

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

This bug was qualified as Confirmed on Trunk (means still existing and reproducible). A Merge Proposal for trunk was created to fix it. Here is the link to follow the MP on Launchpad https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-573362-port-mma/+merge/132242 and be informed once it's been merged in trunk: ... If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Unmerged revisions

6738. By Hardik Ansodariya (OpenERP)

[Fixed] audittrail: fix the problem of recursion if object contains o2m or m2m field of same object(Maintanace Case: 573362)

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-04-26 10:17:23 +0000
4@@ -344,7 +344,12 @@
5 assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj))
6 x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id)
7 #recursive call on x2m fields that need to be checked too
8- data.update(self.get_data(cr, 1, pool, resource[field], x2m_model, method))
9+ field_resource_ids = list(set(resource[field]))
10+ if model.model == x2m_model.model:
11+ # we need to remove current resource_id from the many2many to prevent an infinit loop
12+ if resource_id in field_resource_ids:
13+ field_resource_ids.remove(resource_id)
14+ data.update(self.get_data(cr, 1, pool, field_resource_ids, x2m_model, method))
15 data[(model.id, resource_id)] = {'text':values_text, 'value': values}
16 return data
17
18@@ -402,6 +407,10 @@
19 x2m_new_values_ids = new_values.get(key, {'value': {}})['value'].get(field_name, [])
20 # We use list(set(...)) to remove duplicates.
21 res_ids = list(set(x2m_old_values_ids + x2m_new_values_ids))
22+ if model.model == x2m_model.model:
23+ # we need to remove current resource_id from the many2many to prevent an infinit loop
24+ if resource_id in res_ids:
25+ res_ids.remove(resource_id)
26 for res_id in res_ids:
27 lines.update(self.prepare_audittrail_log_line(cr, 1, pool, x2m_model, res_id, method, old_values, new_values, field_list))
28 # if the value value is different than the old value: record the change