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
1=== modified file 'addons/openerp/widgets/listgrid.py'
2--- addons/openerp/widgets/listgrid.py 2012-11-15 12:41:38 +0000
3+++ addons/openerp/widgets/listgrid.py 2013-05-07 08:24:26 +0000
4@@ -265,7 +265,7 @@
5 if ids and not isinstance(ids, (list, tuple)):
6 ids = [ids]
7
8- if ids and len(ids) > 0:
9+ if ids and len(ids) > 0 and not kw.get('__no_data_fetch'):
10
11 ctx = rpc.session.context.copy()
12 ctx.update(context)
13@@ -291,7 +291,7 @@
14 # update active 'ids' except for many2many which need to get
15 # all known ids for update to work correctly
16 self.ids = ids
17- elif kw.get('default_data', []):
18+ elif kw.get('default_data', []) and not kw.get('__no_data_fetch'):
19 data = kw['default_data']
20
21 self.values = copy.deepcopy(data)
22
23=== modified file 'addons/openerp/widgets/listgroup.py'
24--- addons/openerp/widgets/listgroup.py 2012-07-30 11:08:14 +0000
25+++ addons/openerp/widgets/listgroup.py 2013-05-07 08:24:26 +0000
26@@ -186,14 +186,17 @@
27
28 self.context.update(rpc.session.context.copy())
29
30- if self.group_by_no_leaf:
31+ extra_args = {}
32+
33+ if self.group_by_ctx or self.group_by_no_leaf:
34 self.limit = -1
35+ extra_args['__no_data_fetch'] = True
36
37 super(ListGroup, self).__init__(
38 name=name, model=model, view=view, ids=self.ids, domain=self.domain,
39 context=self.context, limit=self.limit, count=self.count,
40 offset=self.offset, editable=self.editable,
41- selectable=self.selectable)
42+ selectable=self.selectable, **extra_args)
43
44 if self.group_by_ctx:
45 self.context['group_by'] = self.group_by_ctx
46@@ -235,6 +238,7 @@
47 def __init__(self, name, model, view, ids=[], domain=[], parent_group=None, group_level=0, groups = [], context={}, **kw):
48 self.context = context or {}
49 self.domain = domain or []
50+ self.group_by_no_leaf = self.context.get('group_by_no_leaf', 0)
51
52 self.selectable = kw.get('selectable', 0)
53 self.editable = kw.get('editable', False)
54@@ -276,13 +280,17 @@
55 fields = view['fields']
56
57 self.grp_records = []
58+ extra_args = {}
59+
60+ if self.group_by_ctx or self.group_by_no_leaf:
61+ self.limit = -1
62+ extra_args['__no_data_fetch'] = True
63+
64 super(MultipleGroup, self).__init__(
65 name=name, model=model, view=view, ids=self.ids, domain=self.domain,
66 parent_group=parent_group, group_level=group_level, groups=groups, context=self.context, limit=self.limit,
67 count=self.count,offset=self.offset, editable=self.editable,
68- selectable=self.selectable, sort_order=sort_order, sort_key=sort_key)
69-
70- self.group_by_no_leaf = self.context.get('group_by_no_leaf', 0)
71+ selectable=self.selectable, sort_order=sort_order, sort_key=sort_key, **extra_args)
72
73 self.group_by_ctx, self.hiddens, self.headers = parse(self.group_by_ctx, self.hiddens, self.headers, self.group_level, groups)
74
75
76=== modified file 'addons/openerp/widgets/search.py'
77--- addons/openerp/widgets/search.py 2012-07-27 12:12:02 +0000
78+++ addons/openerp/widgets/search.py 2013-05-07 08:24:26 +0000
79@@ -349,9 +349,10 @@
80 attrs['filter_status'] = values['filter_status']
81
82 v = Filter(**attrs)
83- if v.groupcontext and v.groupcontext not in self.groupby:
84- self.groupby.append(v.groupcontext)
85- self.listof_domain.extend(i for i in v.global_domain if not i in self.listof_domain)
86+ if v.def_checked:
87+ if v.groupcontext and v.groupcontext not in self.groupby:
88+ self.groupby.append(v.groupcontext)
89+ self.listof_domain.extend(i for i in v.global_domain if not i in self.listof_domain)
90 filters_run.append(v)
91
92 elif node.localName == 'field':
93@@ -470,10 +471,11 @@
94 filter_field.onchange = None
95 filter_field.callback = None
96
97- if filter_field.groupcontext and filter_field.groupcontext not in self.groupby:
98- self.groupby.append(filter_field.groupcontext)
99- self.listof_domain.extend(i for i in filter_field.global_domain
100- if i not in self.listof_domain)
101+ if filter_field.def_checked:
102+ if filter_field.groupcontext and filter_field.groupcontext not in self.groupby:
103+ self.groupby.append(filter_field.groupcontext)
104+ self.listof_domain.extend(i for i in filter_field.global_domain
105+ if i not in self.listof_domain)
106 field.filters.append(filter_field)
107 if filters_run:
108 views.append(FiltersGroup(children=filters_run))
109
110=== modified file 'addons/openerp/widgets/templates/listgrid/listgroup.mako'
111--- addons/openerp/widgets/templates/listgrid/listgroup.mako 2012-07-18 09:35:52 +0000
112+++ addons/openerp/widgets/templates/listgrid/listgroup.mako 2013-05-07 08:24:26 +0000
113@@ -57,7 +57,7 @@
114
115 % if len(group_by_ctx) == 1 and group_by_no_leaf:
116 <td class="grid-cell"></td>
117- % elif len(group_by_ctx) >= 0:
118+ % elif len(group_by_ctx) >= 1:
119 <td class="grid-cell group-expand"
120 onclick="new ListView('${name}').group_by('${grp_row.get('group_by_id')}', '${grp_row.get('groups_id')}', '${group_by_no_leaf}', this);">
121 </td>