Mohammed Shekha(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-client-web/6.0-opw-383682-msh into 
lp:openobject-client-web.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-383682-msh/+merge/93358

Hello,

Fixed the issue of M2M which has performance issue that when M2M is loaded in 
any form it will go to read all the ids even though we don't need to read all 
the ids we just need to read only ids which comes in pager limit.

Demo:- Load any form view in which there is many2many field, to see whether all 
the ids are read or not, either put server-log or put print statement in 
listgrid.py of controller.

You will see all the ids are read from the server instead of 20 or 50 ids which 
is the limit of pager.

Hence changed the code in _m2m.py to fix the issue.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-383682-msh/+merge/93358
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-client-web/6.0-opw-383682-msh.
=== modified file 'addons/openerp/widgets/form/_m2m.py'
--- addons/openerp/widgets/form/_m2m.py	2011-01-17 11:57:11 +0000
+++ addons/openerp/widgets/form/_m2m.py	2012-02-16 09:15:23 +0000
@@ -81,19 +81,14 @@
         self.switch_to = view_mode[-1]
         if view_type == view_mode[-1]: self.switch_to = view_mode[0]
 
-        if ids is None:
-            ids = attrs.get('value', [])
+        ids = attrs.get('value', [])
 
         id = (ids or None) and ids[0]
         
         pprefix = ''
         if '/' in self.name:
             pprefix = self.name[:self.name.rindex('/')]
-        
-        if self.name == params.source and params.sort_key and ids:
-            self.domain.append(('id', 'in', ids))
-            ids = rpc.RPCProxy(self.model).search(self.domain, 0, 0, params.sort_key+ ' '+params.sort_order, self.context)
-            id = ids[0]
+
         current = params.chain_get(self.name)
 
         if not current:
@@ -103,6 +98,17 @@
         current.limit = current.limit or 50
         current.count = len(ids or [])
 
+        if isinstance(ids, tuple):
+            ids = list(ids)
+
+        if ids and current.limit != -1:
+            ids = ids[current.offset: current.offset+current.limit]
+        
+        if self.name == params.source and params.sort_key and ids:
+            self.domain.append(('id', 'in', ids))
+            ids = rpc.RPCProxy(self.model).search(self.domain, 0, 0, params.sort_key+ ' '+params.sort_order, self.context)
+            id = ids[0]
+
         if current.view_mode: view_mode = current.view_mode
         if current.view_type: view_type = current.view_type
 
@@ -114,9 +120,6 @@
         current.model = self.model
         current.id = id
 
-        if isinstance(ids, tuple):
-            ids = list(ids)
-
         current.ids = ids or []
         current.view_mode = view_mode
         current.view_type = view_type

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to