Merge lp:~openerp-dev/openobject-client-web/6.0-opw-578685-msh into lp:openobject-client-web

Proposed by Mohammed Shekha(Open ERP)
Status: Merged
Approved by: Xavier ALT
Approved revision: 4881
Merged at revision: 4885
Proposed branch: lp:~openerp-dev/openobject-client-web/6.0-opw-578685-msh
Merge into: lp:openobject-client-web
Diff against target: 67 lines (+22/-8)
2 files modified
addons/openerp/widgets/form/_m2m.py (+2/-7)
addons/openerp/widgets/listgrid.py (+20/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/6.0-opw-578685-msh
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+122620@code.launchpad.net

Description of the change

Hello,

Fixed the issue of many2many pager inconsistent behaviour.

Demo:- Create some more records in many2many like in partner category I have 500 records and limit is 50, so now to check inconsistency just click on next paging records in 2/3 times you will get the issue.

when you click next records 2/3 times the count is shown proper but the record will not be appear.

Reason :- The issue is generated due to https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-383682-msh/+merge/93358 because ids were assigned filtered ids based on current.offset and current.limit due to which when next page is opened so we will get only filtered ids in ids.

Thanks.

To post a comment you must log in.
4880. By Xavier ALT

[FIX] web: multiple fix on many2many

4881. By Xavier ALT

[FIX] many2many: prefilter data only when view is not using field sum='' attribute

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/widgets/form/_m2m.py'
2--- addons/openerp/widgets/form/_m2m.py 2012-06-08 16:55:21 +0000
3+++ addons/openerp/widgets/form/_m2m.py 2012-10-09 08:04:24 +0000
4@@ -102,16 +102,11 @@
5 if isinstance(ids, tuple):
6 ids = list(ids)
7
8- if ids and current.limit != -1 and not params.sort_key:
9- ids = ids[current.offset: current.offset+current.limit]
10-
11 if self.name == params.source and params.sort_key and ids:
12+ # reorder ids based on supplier criteria (sort_key, sort_order)
13 domain = current.domain or []
14 domain.append(('id','in',ids))
15- limit = current.limit
16- if current.limit == -1:
17- limit = 0
18- ids = rpc.RPCProxy(self.model).search(domain, current.offset, limit, params.sort_key+ ' '+params.sort_order, current.context)
19+ ids = rpc.RPCProxy(self.model).search(domain, 0, 0, params.sort_key+ ' '+params.sort_order, current.context)
20 id = ids[0]
21
22 if current.view_mode: view_mode = current.view_mode
23
24=== modified file 'addons/openerp/widgets/listgrid.py'
25--- addons/openerp/widgets/listgrid.py 2012-07-31 09:35:50 +0000
26+++ addons/openerp/widgets/listgrid.py 2012-10-09 08:04:24 +0000
27@@ -253,6 +253,12 @@
28 else:
29 self.count = proxy.search_count(search_param, context)
30
31+ if not default_data and self.m2m and not self.view_using_sum_attrs(root):
32+ # for many2many we limits 'ids' to be readed only when view is not
33+ # using sum, otherwise we need to get all 'ids' to compute sums correctly
34+ if ids and self.limit not in (0, -1):
35+ ids = self.ids[self.offset:self.offset+self.limit]
36+
37 self.data_dict = {}
38 data = []
39
40@@ -281,7 +287,10 @@
41 for item in data:
42 self.data_dict[item['id']] = item.copy()
43
44- self.ids = ids
45+ if not self.m2m:
46+ # update active 'ids' except for many2many which need to get
47+ # all known ids for update to work correctly
48+ self.ids = ids
49 elif kw.get('default_data', []):
50 data = kw['default_data']
51
52@@ -419,6 +428,16 @@
53
54 return super(List, self).display(value, **params)
55
56+ def view_using_sum_attrs(self, root):
57+ """ detect if supplied view is using <field sum=""/>
58+
59+ @return: True/False
60+ """
61+ for node in root.childNodes:
62+ if node.nodeName == 'field' and 'attrs' in node_attributes(node):
63+ return True
64+ return False
65+
66 def parse(self, root, fields, data=[]):
67 """Parse the given node to generate valid list headers.
68