Merge lp:~openerp-dev/openobject-client-web/trunk-bug-718552-sma into lp:openobject-client-web/trunk

Proposed by Sananaz (Open ERP)
Status: Merged
Approved by: Xavier (Open ERP)
Approved revision: 4585
Merged at revision: 4588
Proposed branch: lp:~openerp-dev/openobject-client-web/trunk-bug-718552-sma
Merge into: lp:openobject-client-web/trunk
Diff against target: 24 lines (+11/-2)
1 file modified
addons/openerp/utils/tools.py (+11/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/trunk-bug-718552-sma
Reviewer Review Type Date Requested Status
OpenERP R&D Web Team Pending
Review via email: mp+50099@code.launchpad.net
To post a comment you must log in.
4585. By Sananaz (Open ERP)

[IMP] Improved code to evaluate active_id for domain.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/utils/tools.py'
2--- addons/openerp/utils/tools.py 2011-02-10 16:09:23 +0000
3+++ addons/openerp/utils/tools.py 2011-02-17 10:00:59 +0000
4@@ -60,9 +60,18 @@
5 if isinstance(value, list):
6 for index in range(len(value)):
7 domain_element = value[index]
8- if not (isinstance(domain_element, tuple) and domain_element[2] == 'active_id'):
9+ if not (isinstance(domain_element, tuple) and
10+ (domain_element[2] == 'active_id' or (isinstance(domain_element[2],list) and 'active_id' in domain_element[2]))):
11 continue
12- value[index] = (domain_element[0], domain_element[1], context['active_id'])
13+ right_op = domain_element[2]
14+ if isinstance(right_op, list):
15+ #Its very much possible that 'active_id' in in list in any sequence
16+ #eg. ['active_id'], [1,'active_id'],etc.
17+ right_op[right_op.index('active_id')] = context.get('active_id')
18+ else:
19+ #Replacement of right operator with a direct copy of context['active_id']
20+ right_op = context.get('active_id')
21+ value[index] = (domain_element[0], domain_element[1], right_op)
22 elif isinstance(value, dict):
23 for key, v in value.items():
24 if v == 'active_id' or v == ['active_id']: