Merge lp:~jfb-tempo-consulting/unifield-web/US-1019-us15 into lp:unifield-web
- US-1019-us15
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 4977 |
Proposed branch: | lp:~jfb-tempo-consulting/unifield-web/US-1019-us15 |
Merge into: | lp:unifield-web |
Diff against target: |
209 lines (+57/-15) 3 files modified
addons/openerp/static/javascript/search.js (+17/-6) addons/openerp/widgets/search.py (+39/-8) addons/openerp/widgets/templates/search/filters_group.mako (+1/-1) |
To merge this branch: | bzr merge lp:~jfb-tempo-consulting/unifield-web/US-1019-us15 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+374916@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'addons/openerp/static/javascript/search.js' | |||
2 | --- addons/openerp/static/javascript/search.js 2018-10-24 14:22:10 +0000 | |||
3 | +++ addons/openerp/static/javascript/search.js 2019-10-30 13:23:30 +0000 | |||
4 | @@ -440,7 +440,7 @@ | |||
5 | 440 | var check_domain = '[]'; | 440 | var check_domain = '[]'; |
6 | 441 | var domains = {}; | 441 | var domains = {}; |
7 | 442 | var search_context = {}; | 442 | var search_context = {}; |
9 | 443 | var all_boxes = []; | 443 | var all_boxes = {}; |
10 | 444 | var $filter_list = jQuery('#filter_list'); | 444 | var $filter_list = jQuery('#filter_list'); |
11 | 445 | var domain = '[]'; | 445 | var domain = '[]'; |
12 | 446 | if (jQuery('div.group-data').length) { | 446 | if (jQuery('div.group-data').length) { |
13 | @@ -571,17 +571,28 @@ | |||
14 | 571 | 571 | ||
15 | 572 | forEach(selected_boxes, function(box){ | 572 | forEach(selected_boxes, function(box){ |
16 | 573 | if (box.id && box.checked && box.value != '[]') { | 573 | if (box.id && box.checked && box.value != '[]') { |
18 | 574 | all_boxes = all_boxes.concat(box.value); | 574 | |
19 | 575 | pdiv = box.closest('div[class^="filters-group"]'); | ||
20 | 576 | if (!(pdiv.id in all_boxes)) { | ||
21 | 577 | all_boxes[pdiv.id] = [] | ||
22 | 578 | } | ||
23 | 579 | all_boxes[pdiv.id].push(box.value.replace(/^\s*\[/, '').replace(/]\s*$/, '')); | ||
24 | 575 | } | 580 | } |
25 | 576 | }); | 581 | }); |
26 | 577 | 582 | ||
28 | 578 | var checked_button = all_boxes.toString(); | 583 | var new_boxes = []; |
29 | 584 | for (var key in all_boxes) { | ||
30 | 585 | length = all_boxes[key].length | ||
31 | 586 | for (var i=1; i<length; i+=1) { | ||
32 | 587 | all_boxes[key].unshift("'|'"); | ||
33 | 588 | } | ||
34 | 589 | new_boxes = new_boxes.concat(all_boxes[key]); | ||
35 | 590 | } | ||
36 | 591 | var checked_button = new_boxes.toString(); | ||
37 | 579 | 592 | ||
38 | 580 | if(checked_button.length) { | 593 | if(checked_button.length) { |
41 | 581 | check_domain = checked_button.length > 0? checked_button.replace(/(],\[)/g, ', ') : '[]'; | 594 | all_domains['check_domain'] = checked_button.length > 0 ? '['+checked_button+']' : '[]'; |
40 | 582 | all_domains['check_domain'] = check_domain; | ||
42 | 583 | } | 595 | } |
43 | 584 | |||
44 | 585 | // compute filter_status based on current filter states | 596 | // compute filter_status based on current filter states |
45 | 586 | var fl_status = {}; | 597 | var fl_status = {}; |
46 | 587 | jQuery('[filter_status]').each(function() { | 598 | jQuery('[filter_status]').each(function() { |
47 | 588 | 599 | ||
48 | === modified file 'addons/openerp/widgets/search.py' | |||
49 | --- addons/openerp/widgets/search.py 2018-11-12 17:08:16 +0000 | |||
50 | +++ addons/openerp/widgets/search.py 2019-10-30 13:23:30 +0000 | |||
51 | @@ -37,9 +37,10 @@ | |||
52 | 37 | from openobject.i18n.format import convert_date_format_in_domain | 37 | from openobject.i18n.format import convert_date_format_in_domain |
53 | 38 | 38 | ||
54 | 39 | 39 | ||
56 | 40 | def get_search_default(attrs, screen_context=None, default_domain=[]): | 40 | def get_search_default(attrs, screen_context=None, default_domain=None, add_active=False): |
57 | 41 | screen_context = screen_context or {} | 41 | screen_context = screen_context or {} |
59 | 42 | 42 | if default_domain is None: | |
60 | 43 | default_domain = [] | ||
61 | 43 | if 'context' in attrs: | 44 | if 'context' in attrs: |
62 | 44 | ctx = expr_eval(attrs.get('context', "{}"), {'self':attrs.get('name', False)}) | 45 | ctx = expr_eval(attrs.get('context', "{}"), {'self':attrs.get('name', False)}) |
63 | 45 | group_by = ctx.get('group_by') | 46 | group_by = ctx.get('group_by') |
64 | @@ -63,6 +64,8 @@ | |||
65 | 63 | # resolution of those, so either we have a truthy value and we | 64 | # resolution of those, so either we have a truthy value and we |
66 | 64 | # return it, or we don't and we don't do anything | 65 | # return it, or we don't and we don't do anything |
67 | 65 | return search_default | 66 | return search_default |
68 | 67 | elif add_active and attrs['name'] == 'active' and 'active' not in '%s'%default_domain: | ||
69 | 68 | return True | ||
70 | 66 | 69 | ||
71 | 67 | return False | 70 | return False |
72 | 68 | 71 | ||
73 | @@ -129,13 +132,14 @@ | |||
74 | 129 | self.filter_id = 'filter_%s' % (random.randint(0,10000)) | 132 | self.filter_id = 'filter_%s' % (random.randint(0,10000)) |
75 | 130 | self.filter_name = attrs.get('name', attrs.get('string', '')).replace('/', '-') | 133 | self.filter_name = attrs.get('name', attrs.get('string', '')).replace('/', '-') |
76 | 131 | self.filter_status = attrs.get('filter_status', {}).get(self.filter_name) | 134 | self.filter_status = attrs.get('filter_status', {}).get(self.filter_name) |
77 | 135 | self.expand_grp_id = False | ||
78 | 132 | filter_context = attrs.get('context') | 136 | filter_context = attrs.get('context') |
79 | 133 | screen_context = attrs.get('screen_context', {}) | 137 | screen_context = attrs.get('screen_context', {}) |
80 | 134 | 138 | ||
81 | 135 | self.def_checked = False | 139 | self.def_checked = False |
82 | 136 | self.groupcontext = [] | 140 | self.groupcontext = [] |
83 | 137 | 141 | ||
85 | 138 | default_search = get_search_default(attrs, screen_context, default_domain) | 142 | default_search = get_search_default(attrs, screen_context, default_domain, add_active=True) |
86 | 139 | 143 | ||
87 | 140 | # context implemented only for group_by. | 144 | # context implemented only for group_by. |
88 | 141 | self.group_context = None | 145 | self.group_context = None |
89 | @@ -147,9 +151,10 @@ | |||
90 | 147 | self.group_context = map(lambda x: 'group_' + x, self.group_context) | 151 | self.group_context = map(lambda x: 'group_' + x, self.group_context) |
91 | 148 | else: | 152 | else: |
92 | 149 | self.group_context = 'group_' + self.group_context | 153 | self.group_context = 'group_' + self.group_context |
93 | 150 | |||
94 | 151 | if default_search: | 154 | if default_search: |
95 | 152 | self.def_checked = True | 155 | self.def_checked = True |
96 | 156 | if attrs.get('expand_grp_id'): | ||
97 | 157 | self.expand_grp_id = attrs['expand_grp_id'] | ||
98 | 153 | self.global_domain += (expr_eval(self.filter_domain, {'context':screen_context})) | 158 | self.global_domain += (expr_eval(self.filter_domain, {'context':screen_context})) |
99 | 154 | if self.group_context: | 159 | if self.group_context: |
100 | 155 | self.groupcontext = self.group_context | 160 | self.groupcontext = self.group_context |
101 | @@ -202,6 +207,7 @@ | |||
102 | 202 | 207 | ||
103 | 203 | self.domain = copy.deepcopy(domain) or [] | 208 | self.domain = copy.deepcopy(domain) or [] |
104 | 204 | self.listof_domain = domain or [] | 209 | self.listof_domain = domain or [] |
105 | 210 | self.listof_ored_domain = {} | ||
106 | 205 | self.filter_domain = filter_domain or [] | 211 | self.filter_domain = filter_domain or [] |
107 | 206 | self.filter_status = {} | 212 | self.filter_status = {} |
108 | 207 | self.custom_filter_domain = [] | 213 | self.custom_filter_domain = [] |
109 | @@ -267,6 +273,11 @@ | |||
110 | 267 | self.fields_list.sort(lambda x, y: cmp(x[1], y[1])) | 273 | self.fields_list.sort(lambda x, y: cmp(x[1], y[1])) |
111 | 268 | 274 | ||
112 | 269 | self.frame = self.parse(model, dom, self.fields, values) | 275 | self.frame = self.parse(model, dom, self.fields, values) |
113 | 276 | for oreddom in self.listof_ored_domain: | ||
114 | 277 | for el in range(1, len(self.listof_ored_domain[oreddom])): | ||
115 | 278 | self.listof_ored_domain[oreddom].insert(0, '|') | ||
116 | 279 | for oredfilter in self.listof_ored_domain[oreddom]: | ||
117 | 280 | self.listof_domain += oredfilter | ||
118 | 270 | if self.frame: | 281 | if self.frame: |
119 | 271 | self.frame = self.frame[0] | 282 | self.frame = self.frame[0] |
120 | 272 | 283 | ||
121 | @@ -296,7 +307,7 @@ | |||
122 | 296 | self.flt_domain = str(self.filter_domain).replace("(", "[").replace(')', ']') | 307 | self.flt_domain = str(self.filter_domain).replace("(", "[").replace(')', ']') |
123 | 297 | self.custom_filter_domain = self.filter_domain | 308 | self.custom_filter_domain = self.filter_domain |
124 | 298 | 309 | ||
126 | 299 | def parse(self, model=None, root=None, fields=None, values={}): | 310 | def parse(self, model=None, root=None, fields=None, values={}, parent_group=False): |
127 | 300 | 311 | ||
128 | 301 | views = [] | 312 | views = [] |
129 | 302 | search_model = model | 313 | search_model = model |
130 | @@ -317,19 +328,23 @@ | |||
131 | 317 | if 'nolabel' in attrs: | 328 | if 'nolabel' in attrs: |
132 | 318 | attrs['nolabel'] = False | 329 | attrs['nolabel'] = False |
133 | 319 | 330 | ||
134 | 331 | expand_grp_id = False | ||
135 | 320 | if node.localName in ('form', 'tree', 'search', 'group'): | 332 | if node.localName in ('form', 'tree', 'search', 'group'): |
136 | 321 | if node.localName == 'group': | 333 | if node.localName == 'group': |
137 | 322 | attrs['group_by_ctx'] = values.get('group_by_ctx') | 334 | attrs['group_by_ctx'] = values.get('group_by_ctx') |
138 | 323 | attrs['expand'] = expr_eval(attrs.get('expand',False),{'context':self.context}) | 335 | attrs['expand'] = expr_eval(attrs.get('expand',False),{'context':self.context}) |
139 | 336 | expand_grp_id = 'expand_grp_%s' % (random.randint(0,10000)) | ||
140 | 324 | Element = Group | 337 | Element = Group |
141 | 325 | else: | 338 | else: |
142 | 326 | Element = Frame | 339 | Element = Frame |
143 | 327 | 340 | ||
144 | 328 | views.append(Element(children= | 341 | views.append(Element(children= |
145 | 329 | self.parse(model=search_model, root=node, | 342 | self.parse(model=search_model, root=node, |
147 | 330 | fields=fields, values=values), | 343 | fields=fields, values=values, parent_group=expand_grp_id), |
148 | 331 | **attrs)) | 344 | **attrs)) |
149 | 332 | 345 | ||
150 | 346 | elif node.localName=='label': | ||
151 | 347 | views.append(Label(**attrs)) | ||
152 | 333 | elif node.localName=='newline': | 348 | elif node.localName=='newline': |
153 | 334 | views.append(NewLine(**attrs)) | 349 | views.append(NewLine(**attrs)) |
154 | 335 | 350 | ||
155 | @@ -346,12 +361,19 @@ | |||
156 | 346 | if values and values.get('filter_status'): | 361 | if values and values.get('filter_status'): |
157 | 347 | attrs['filter_status'] = values['filter_status'] | 362 | attrs['filter_status'] = values['filter_status'] |
158 | 348 | 363 | ||
159 | 364 | if parent_group: | ||
160 | 365 | attrs['expand_grp_id'] = parent_group | ||
161 | 349 | v = Filter(**attrs) | 366 | v = Filter(**attrs) |
162 | 350 | if v.groupcontext and v.groupcontext not in self.groupby: | 367 | if v.groupcontext and v.groupcontext not in self.groupby: |
163 | 351 | self.groupby.append(v.groupcontext) | 368 | self.groupby.append(v.groupcontext) |
165 | 352 | self.listof_domain.extend(i for i in v.global_domain if not i in self.listof_domain) | 369 | if v.global_domain and v.expand_grp_id: |
166 | 370 | self.listof_ored_domain.setdefault(v.expand_grp_id, []).append([i for i in v.global_domain]) | ||
167 | 371 | else: | ||
168 | 372 | self.listof_domain.extend(i for i in v.global_domain if not i in self.listof_domain) | ||
169 | 353 | filters_run.append(v) | 373 | filters_run.append(v) |
170 | 354 | 374 | ||
171 | 375 | elif node.localName == 'separator': | ||
172 | 376 | parent_group = 'expand_grp_%s' % (random.randint(0,10000)) | ||
173 | 355 | elif node.localName == 'field': | 377 | elif node.localName == 'field': |
174 | 356 | val = attrs.get('select', False) or fields[str(attrs['name'])].get('select', False) or self.view_type == 'search' | 378 | val = attrs.get('select', False) or fields[str(attrs['name'])].get('select', False) or self.view_type == 'search' |
175 | 357 | if val: | 379 | if val: |
176 | @@ -494,6 +516,14 @@ | |||
177 | 494 | attrs['is_search'] = True | 516 | attrs['is_search'] = True |
178 | 495 | super(FiltersGroup, self).__init__(**attrs) | 517 | super(FiltersGroup, self).__init__(**attrs) |
179 | 496 | 518 | ||
180 | 519 | class Label(form.Char): | ||
181 | 520 | template = "/openerp/widgets/templates/search/label.mako" | ||
182 | 521 | width = False | ||
183 | 522 | name = 'label' | ||
184 | 523 | def __init__(self, **attrs): | ||
185 | 524 | super(Label, self).__init__(**attrs) | ||
186 | 525 | |||
187 | 526 | |||
188 | 497 | class Char(form.Char): pass | 527 | class Char(form.Char): pass |
189 | 498 | class DateTime(form.DateTime): pass | 528 | class DateTime(form.DateTime): pass |
190 | 499 | class Float(form.Float): pass | 529 | class Float(form.Float): pass |
191 | @@ -538,5 +568,6 @@ | |||
192 | 538 | 'many2one': M2O_search, | 568 | 'many2one': M2O_search, |
193 | 539 | 'email' : Char, | 569 | 'email' : Char, |
194 | 540 | 'url' : Char, | 570 | 'url' : Char, |
196 | 541 | 'separator': Separator | 571 | 'separator': Separator, |
197 | 572 | 'label': Label, | ||
198 | 542 | } | 573 | } |
199 | 543 | 574 | ||
200 | === modified file 'addons/openerp/widgets/templates/search/filters_group.mako' | |||
201 | --- addons/openerp/widgets/templates/search/filters_group.mako 2010-10-15 11:10:50 +0000 | |||
202 | +++ addons/openerp/widgets/templates/search/filters_group.mako 2019-10-30 13:23:30 +0000 | |||
203 | @@ -1,3 +1,3 @@ | |||
205 | 1 | <div class="filters-group"> | 1 | <div class="filters-group" id="grp-filter-${expand_grp_id}"> |
206 | 2 | ${display_member(frame)} | 2 | ${display_member(frame)} |
207 | 3 | </div> | 3 | </div> |
208 | 4 | 4 | ||
209 | === added file 'addons/openerp/widgets/templates/search/label.mako' |