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
1=== modified file 'bin/modules/gui/window/form.py'
2--- bin/modules/gui/window/form.py 2011-02-01 13:58:58 +0000
3+++ bin/modules/gui/window/form.py 2011-07-05 14:36:52 +0000
4@@ -158,19 +158,29 @@
5 ## and needed to be converted to real ids
6 if isinstance(get_id, str):
7 get_id = int(get_id.split('-')[0])
8- all_ids = rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'search', [])
9+
10 if widget:
11 get_id = int(widget.get_value())
12- if get_id in all_ids:
13- current_ids = self.screen.ids_get()
14- if get_id in current_ids:
15- self.screen.display(get_id)
16- else:
17+
18+ # We need listed / searched set of IDS when we switch back to a view
19+ listed_ids = self.screen.ids_get()
20+
21+ ## If the record is already among the previously searched records or inside
22+ ## the listed_ids, we do not need to call search
23+ record_exists = False
24+ if get_id in listed_ids:
25+ self.screen.display(get_id)
26+ record_exists = True
27+ else:
28+ # User is trying to see the record with Ctrl + G option! So we search domainless, limitless!
29+ record_exists = rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'search', [('id','=',get_id)], False, False, False, self.screen.context)
30+ if record_exists:
31 self.screen.load([get_id])
32+
33+ if get_id and record_exists:
34 self.screen.current_view.set_cursor()
35 else:
36- if widget:
37- common.message(_('Resource ID does not exist for this object!'))
38+ common.message(_('Resource ID does not exist for this object!'))
39
40 def get_event(self, widget, event, win):
41 if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):