Merge lp:~openerp-dev/openobject-client/6.0-opw-15282-jvo into lp:openobject-client/6.0

Proposed by Jay Vora (Serpent Consulting Services)
Status: Merged
Merged at revision: 1868
Proposed branch: lp:~openerp-dev/openobject-client/6.0-opw-15282-jvo
Merge into: lp:openobject-client/6.0
Diff against target: 41 lines (+18/-8)
1 file modified
bin/modules/gui/window/form.py (+18/-8)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client/6.0-opw-15282-jvo
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+66888@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
1868. By Jay Vora (Serpent Consulting Services)

[FIX] get_resource() corrected in order to speed up the process by removing extra RPC search call

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Thanks for approving it Olivier.

This merge will remove unnecessary search call and will let the system work faster while switching the views and while searching a desired record(resource) by Pressing Ctrl+ G (in GTK).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 14:36:52 +0000
@@ -158,19 +158,29 @@
158 ## and needed to be converted to real ids158 ## and needed to be converted to real ids
159 if isinstance(get_id, str):159 if isinstance(get_id, str):
160 get_id = int(get_id.split('-')[0])160 get_id = int(get_id.split('-')[0])
161 all_ids = rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'search', [])161
162 if widget:162 if widget:
163 get_id = int(widget.get_value())163 get_id = int(widget.get_value())
164 if get_id in all_ids:164
165 current_ids = self.screen.ids_get()165 # We need listed / searched set of IDS when we switch back to a view
166 if get_id in current_ids:166 listed_ids = self.screen.ids_get()
167 self.screen.display(get_id)167
168 else:168 ## If the record is already among the previously searched records or inside
169 ## the listed_ids, we do not need to call search
170 record_exists = False
171 if get_id in listed_ids:
172 self.screen.display(get_id)
173 record_exists = True
174 else:
175 # User is trying to see the record with Ctrl + G option! So we search domainless, limitless!
176 record_exists = rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'search', [('id','=',get_id)], False, False, False, self.screen.context)
177 if record_exists:
169 self.screen.load([get_id])178 self.screen.load([get_id])
179
180 if get_id and record_exists:
170 self.screen.current_view.set_cursor()181 self.screen.current_view.set_cursor()
171 else:182 else:
172 if widget:183 common.message(_('Resource ID does not exist for this object!'))
173 common.message(_('Resource ID does not exist for this object!'))
174184
175 def get_event(self, widget, event, win):185 def get_event(self, widget, event, win):
176 if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):186 if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):