Jay Vora (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-client/6.0-opw-15282-jvo into 
lp:openobject-client/6.0.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client/6.0-opw-15282-jvo/+merge/66888

GTK calls an extra time search() with domain=[]

Steps:
* create a lot of records (example: partners), for example by duplicating 
existing one. I tested with more or less 200 partners
* execute a search query: try to get only 2 or 3 records. I searched for "name 
= asus"
* switch to form view
* switch back to list view
-> sql query uses "where active = 't'" but no other criteria is used, not even 
name ilike '%asus%'
     the domain sued by the sarch is an empty list: [] instead of [('name', 
'ilike', 'asus')]
     Note: v5 client used the correct domain

Problem is with get_resource() which forcefully called search([]).

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-client/6.0-opw-15282-jvo/+merge/66888
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-client/6.0-opw-15282-jvo.
=== modified file 'bin/modules/gui/window/form.py'
--- bin/modules/gui/window/form.py	2011-02-01 13:58:58 +0000
+++ bin/modules/gui/window/form.py	2011-07-05 11:45:53 +0000
@@ -158,19 +158,30 @@
         ## and needed to be converted to real ids
         if isinstance(get_id, str):
             get_id = int(get_id.split('-')[0])
-        all_ids = rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'search', [])
+
         if widget:
             get_id = int(widget.get_value())
-        if get_id in all_ids:
-            current_ids = self.screen.ids_get()
-            if get_id in current_ids:
-                self.screen.display(get_id)
-            else:
+            
+        # We need listed / searched set of IDS when we switch back to a view
+        listed_ids = self.screen.ids_get()
+        
+        ## If the record is already among the previously searched records or inside
+        ## the listed_ids, we do not need to call search
+        record_exists = False
+        if get_id in listed_ids:
+            self.screen.display(get_id)
+            record_exists = True
+        else:
+            # User is trying to see the record with Ctrl + G option! So we search domainless, limitless!
+            all_ids = rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'search', [])
+            if get_id in all_ids:
                 self.screen.load([get_id])
+                record_exists = True
+        
+        if get_id and record_exists:
             self.screen.current_view.set_cursor()
         else:
-            if widget:
-                common.message(_('Resource ID does not exist for this object!'))
+            common.message(_('Resource ID does not exist for this object!'))
 
     def get_event(self, widget, event, win):
         if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):

_______________________________________________
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