Merge lp:~openerp-dev/openobject-client-web/6.0-opw-591397-xal into lp:openobject-client-web

Proposed by Xavier ALT
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-client-web/6.0-opw-591397-xal
Merge into: lp:openobject-client-web
Diff against target: 121 lines (+25/-15)
4 files modified
addons/openerp/widgets/listgrid.py (+2/-2)
addons/openerp/widgets/listgroup.py (+13/-5)
addons/openerp/widgets/search.py (+9/-7)
addons/openerp/widgets/templates/listgrid/listgroup.mako (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/6.0-opw-591397-xal
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+162727@code.launchpad.net

Description of the change

Hi,

This fixes multiple things:

- List should not fetch any data in grouped mode - this is handled by Listgroup and MultipleGroup themself (using read_group).
  => This effectively fix some performance problem cause by reading all records (limit = -1 in grouped mode).

- When having 'search_default_FILTERNAME' in context, even when user uncheck this filter 'FILTERNAME' the list was still considering this filter groupby and domain.

- When having 'group_by_no_leaf' in context and no grouping criteria the list was showing 'row expand' which is wrong.

Regards,
Xavier

To post a comment you must log in.

Unmerged revisions

4915. By Xavier ALT

[FIX] list: prevent List from fetching unnecessary data in grouped mode - this is handled by Listgroup and MultipleGroup themselve

4914. By Xavier ALT

[FIX] list: when view has 'group_by_no_leaf' in context and no grouping key - the view was badly showing row expand

4913. By Xavier ALT

[FIX] search view: fix filter no considering user choice when filter is active by default (considering the context)

  - If filter is active by default (search_default_FILTERNAME) it's domain and
    context was wrongly added if user manually uncheck it (search_data = {FILTERNAME: 0}).

    We now consider filter domain + context depending on 'def_checked' value - which
    respect both default value and user choice.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/openerp/widgets/listgrid.py'
--- addons/openerp/widgets/listgrid.py 2012-11-15 12:41:38 +0000
+++ addons/openerp/widgets/listgrid.py 2013-05-07 08:24:26 +0000
@@ -265,7 +265,7 @@
265 if ids and not isinstance(ids, (list, tuple)):265 if ids and not isinstance(ids, (list, tuple)):
266 ids = [ids]266 ids = [ids]
267267
268 if ids and len(ids) > 0:268 if ids and len(ids) > 0 and not kw.get('__no_data_fetch'):
269269
270 ctx = rpc.session.context.copy()270 ctx = rpc.session.context.copy()
271 ctx.update(context)271 ctx.update(context)
@@ -291,7 +291,7 @@
291 # update active 'ids' except for many2many which need to get291 # update active 'ids' except for many2many which need to get
292 # all known ids for update to work correctly292 # all known ids for update to work correctly
293 self.ids = ids293 self.ids = ids
294 elif kw.get('default_data', []):294 elif kw.get('default_data', []) and not kw.get('__no_data_fetch'):
295 data = kw['default_data']295 data = kw['default_data']
296296
297 self.values = copy.deepcopy(data)297 self.values = copy.deepcopy(data)
298298
=== modified file 'addons/openerp/widgets/listgroup.py'
--- addons/openerp/widgets/listgroup.py 2012-07-30 11:08:14 +0000
+++ addons/openerp/widgets/listgroup.py 2013-05-07 08:24:26 +0000
@@ -186,14 +186,17 @@
186186
187 self.context.update(rpc.session.context.copy())187 self.context.update(rpc.session.context.copy())
188188
189 if self.group_by_no_leaf:189 extra_args = {}
190
191 if self.group_by_ctx or self.group_by_no_leaf:
190 self.limit = -1192 self.limit = -1
193 extra_args['__no_data_fetch'] = True
191194
192 super(ListGroup, self).__init__(195 super(ListGroup, self).__init__(
193 name=name, model=model, view=view, ids=self.ids, domain=self.domain,196 name=name, model=model, view=view, ids=self.ids, domain=self.domain,
194 context=self.context, limit=self.limit, count=self.count,197 context=self.context, limit=self.limit, count=self.count,
195 offset=self.offset, editable=self.editable,198 offset=self.offset, editable=self.editable,
196 selectable=self.selectable)199 selectable=self.selectable, **extra_args)
197200
198 if self.group_by_ctx:201 if self.group_by_ctx:
199 self.context['group_by'] = self.group_by_ctx202 self.context['group_by'] = self.group_by_ctx
@@ -235,6 +238,7 @@
235 def __init__(self, name, model, view, ids=[], domain=[], parent_group=None, group_level=0, groups = [], context={}, **kw):238 def __init__(self, name, model, view, ids=[], domain=[], parent_group=None, group_level=0, groups = [], context={}, **kw):
236 self.context = context or {}239 self.context = context or {}
237 self.domain = domain or []240 self.domain = domain or []
241 self.group_by_no_leaf = self.context.get('group_by_no_leaf', 0)
238242
239 self.selectable = kw.get('selectable', 0)243 self.selectable = kw.get('selectable', 0)
240 self.editable = kw.get('editable', False)244 self.editable = kw.get('editable', False)
@@ -276,13 +280,17 @@
276 fields = view['fields']280 fields = view['fields']
277281
278 self.grp_records = []282 self.grp_records = []
283 extra_args = {}
284
285 if self.group_by_ctx or self.group_by_no_leaf:
286 self.limit = -1
287 extra_args['__no_data_fetch'] = True
288
279 super(MultipleGroup, self).__init__(289 super(MultipleGroup, self).__init__(
280 name=name, model=model, view=view, ids=self.ids, domain=self.domain,290 name=name, model=model, view=view, ids=self.ids, domain=self.domain,
281 parent_group=parent_group, group_level=group_level, groups=groups, context=self.context, limit=self.limit,291 parent_group=parent_group, group_level=group_level, groups=groups, context=self.context, limit=self.limit,
282 count=self.count,offset=self.offset, editable=self.editable,292 count=self.count,offset=self.offset, editable=self.editable,
283 selectable=self.selectable, sort_order=sort_order, sort_key=sort_key)293 selectable=self.selectable, sort_order=sort_order, sort_key=sort_key, **extra_args)
284
285 self.group_by_no_leaf = self.context.get('group_by_no_leaf', 0)
286294
287 self.group_by_ctx, self.hiddens, self.headers = parse(self.group_by_ctx, self.hiddens, self.headers, self.group_level, groups)295 self.group_by_ctx, self.hiddens, self.headers = parse(self.group_by_ctx, self.hiddens, self.headers, self.group_level, groups)
288296
289297
=== modified file 'addons/openerp/widgets/search.py'
--- addons/openerp/widgets/search.py 2012-07-27 12:12:02 +0000
+++ addons/openerp/widgets/search.py 2013-05-07 08:24:26 +0000
@@ -349,9 +349,10 @@
349 attrs['filter_status'] = values['filter_status']349 attrs['filter_status'] = values['filter_status']
350350
351 v = Filter(**attrs)351 v = Filter(**attrs)
352 if v.groupcontext and v.groupcontext not in self.groupby:352 if v.def_checked:
353 self.groupby.append(v.groupcontext)353 if v.groupcontext and v.groupcontext not in self.groupby:
354 self.listof_domain.extend(i for i in v.global_domain if not i in self.listof_domain)354 self.groupby.append(v.groupcontext)
355 self.listof_domain.extend(i for i in v.global_domain if not i in self.listof_domain)
355 filters_run.append(v)356 filters_run.append(v)
356357
357 elif node.localName == 'field':358 elif node.localName == 'field':
@@ -470,10 +471,11 @@
470 filter_field.onchange = None471 filter_field.onchange = None
471 filter_field.callback = None472 filter_field.callback = None
472473
473 if filter_field.groupcontext and filter_field.groupcontext not in self.groupby:474 if filter_field.def_checked:
474 self.groupby.append(filter_field.groupcontext)475 if filter_field.groupcontext and filter_field.groupcontext not in self.groupby:
475 self.listof_domain.extend(i for i in filter_field.global_domain476 self.groupby.append(filter_field.groupcontext)
476 if i not in self.listof_domain)477 self.listof_domain.extend(i for i in filter_field.global_domain
478 if i not in self.listof_domain)
477 field.filters.append(filter_field)479 field.filters.append(filter_field)
478 if filters_run:480 if filters_run:
479 views.append(FiltersGroup(children=filters_run))481 views.append(FiltersGroup(children=filters_run))
480482
=== modified file 'addons/openerp/widgets/templates/listgrid/listgroup.mako'
--- addons/openerp/widgets/templates/listgrid/listgroup.mako 2012-07-18 09:35:52 +0000
+++ addons/openerp/widgets/templates/listgrid/listgroup.mako 2013-05-07 08:24:26 +0000
@@ -57,7 +57,7 @@
5757
58 % if len(group_by_ctx) == 1 and group_by_no_leaf:58 % if len(group_by_ctx) == 1 and group_by_no_leaf:
59 <td class="grid-cell"></td>59 <td class="grid-cell"></td>
60 % elif len(group_by_ctx) >= 0:60 % elif len(group_by_ctx) >= 1:
61 <td class="grid-cell group-expand"61 <td class="grid-cell group-expand"
62 onclick="new ListView('${name}').group_by('${grp_row.get('group_by_id')}', '${grp_row.get('groups_id')}', '${group_by_no_leaf}', this);">62 onclick="new ListView('${name}').group_by('${grp_row.get('group_by_id')}', '${grp_row.get('groups_id')}', '${group_by_no_leaf}', this);">
63 </td>63 </td>