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

Proposed by Mohammed Shekha(Open ERP)
Status: Merged
Merged at revision: 4776
Proposed branch: lp:~openerp-dev/openobject-client-web/6.0-opw-383575-msh
Merge into: lp:openobject-client-web
Diff against target: 40 lines (+11/-5)
1 file modified
addons/openerp/widgets/form/_o2m.py (+11/-5)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/6.0-opw-383575-msh
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+92917@code.launchpad.net

Description of the change

Hello,

Fixed the issue of one2many pager which ignores pager count when sorting also the one2many reads all the records even though limit set to 20 or 50.

Case 383575
Demo :- When one2many of any form view is loaded, it will read all the ids even though I have set limit=20 or 50.

For e.g.
if have 400 records and set the limit to 50, 50 records are
shown, but the web client reads 400 records from the server !

Case 383574
Demo:- Open any form view in which there is one2many field, now sort the one2many field by header label, here the pager is stop to working.

say if I have 55 records and limit=50, now I sort it by header label, you will see the pager will stop to work or it will show wrong counter.

Changed the code in _o2m so that both the issue fixed.

Thanks.

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/widgets/form/_o2m.py'
2--- addons/openerp/widgets/form/_o2m.py 2011-04-06 13:01:31 +0000
3+++ addons/openerp/widgets/form/_o2m.py 2012-02-14 06:39:23 +0000
4@@ -142,6 +142,13 @@
5 if not isinstance(ids, list):
6 ids = [ids]
7
8+ current.offset = current.offset or 0
9+ current.limit = current.limit or 50
10+ current.count = len(ids or [])
11+
12+ if current.limit != -1 and not params.sort_key:
13+ ids = ids[current.offset: current.offset+current.limit]
14+
15 if ids:
16 if isinstance(ids[0], dict):
17 current.default_data = ids
18@@ -159,7 +166,10 @@
19 if params.sort_key and ids:
20 domain = current.domain or []
21 domain.append(('id', 'in', ids))
22- ids = rpc.RPCProxy(self.model).search(domain, current.offset, current.limit, params.sort_key + ' '+params.sort_order, current.context)
23+ limit = current.limit
24+ if current.limit == -1:
25+ limit = 0
26+ ids = rpc.RPCProxy(self.model).search(domain, current.offset, limit, params.sort_key + ' '+params.sort_order, current.context)
27 id = ids[0]
28 if current and params.source and self.name in params.source.split('/'):
29 id = current.id
30@@ -195,10 +205,6 @@
31 if ctx and ctx.get('group_by'):
32 group_by_ctx = ctx.get('group_by')
33
34- current.offset = current.offset or 0
35- current.limit = current.limit or 50
36- current.count = len(ids or [])
37-
38 # Group By for one2many list.
39 if group_by_ctx:
40 current.group_by_ctx = group_by_ctx