Merge lp:~openerp-dev/openobject-client-web/trunk-improved-searchview-cpa into lp:openobject-client-web/trunk

Proposed by Chirag Patel (OpenERP)
Status: Merged
Approved by: Xavier (Open ERP)
Approved revision: 4585
Merged at revision: 4601
Proposed branch: lp:~openerp-dev/openobject-client-web/trunk-improved-searchview-cpa
Merge into: lp:openobject-client-web/trunk
Diff against target: 61 lines (+7/-12)
2 files modified
addons/openerp/controllers/search.py (+1/-3)
addons/openerp/static/javascript/search.js (+6/-9)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/trunk-improved-searchview-cpa
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Needs Information
Chirag Patel (OpenERP) Needs Resubmitting
Review via email: mp+50113@code.launchpad.net

Description of the change

Hello,

Fixed search view issues, Check with the following steps.

steps:
Go to list view of partner(same - any object), add your custom filter and go to form view,switch back to list view and try to apply filter - group by or any thing.It doesn't work.I have to clear the filter first and then need to restart again so for example :
    i) first I have filtered my data with country and opened form view for particular partner but then I feel I need some more filtration so will go back to list view
    ii) and will try to add another filter,let say language - but at this time filters are not working ,neither custom nor default.Even group by is not working either.

Thanks.

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

* Why do you replace a JSON load by an eval (unrestricted too, not just a literal eval)?

* Why do you munge around with the filter value (removing '%') when the problem here is that this value should *not* have %'s in it because the server takes care of adding the '%' markers to ilike values?

* Could you explain what the problem was and why adding a conditional fixes it?

* from an efficiency standpoint, you added a conditional test within a loop. The loop is performed on the parent's children, and you test on the children's parent, so you could just perform the test on jQuery(this) outside the loop, which would avoid traversing the children and going up to the parent again. Either filter as now (via an if) or use .filter

* do not test visibility by checking for a CSS property, there is more to visibility than that and jQuery takes care of it via the `:visible` and `:hidden` pseudo-classes. They're also much clearer in terms of intent.

review: Needs Fixing
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Also, please correctly indent the code you edit, as you can see in the diff view below the indentation is all broken up.

4585. By Chirag Patel (OpenERP)

[Fix] Fixed reviewed code.

Revision history for this message
Chirag Patel (OpenERP) (cpa-openerp) :
review: Needs Resubmitting
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Could you reply to questions 1 and 3? (I'm not saying there's a problem there, I just want to understand)

review: Needs Information
Revision history for this message
Chirag Patel (OpenERP) (cpa-openerp) wrote :

> * Why do you replace a JSON load by an eval (unrestricted too, not just a
> literal eval)?

In commit 4584, I removed json loads because when passing the search value in search.js function "switch_searchView", javascript stops execution because we eval the value like "[[u'country', u'ilike', u'%fr%']]". So eval value from py and passing it to script.

>
> * Why do you munge around with the filter value (removing '%') when the
> problem here is that this value should *not* have %'s in it because the server
> takes care of adding the '%' markers to ilike values?
>
> * Could you explain what the problem was and why adding a conditional fixes
> it?

And I put condition in loop to get object. But it was mistake so I changed accordingly as you said.

>
> * from an efficiency standpoint, you added a conditional test within a loop.
> The loop is performed on the parent's children, and you test on the children's
> parent, so you could just perform the test on jQuery(this) outside the loop,
> which would avoid traversing the children and going up to the parent again.
> Either filter as now (via an if) or use .filter
>
> * do not test visibility by checking for a CSS property, there is more to
> visibility than that and jQuery takes care of it via the `:visible` and
> `:hidden` pseudo-classes. They're also much clearer in terms of intent.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/search.py'
2--- addons/openerp/controllers/search.py 2011-02-17 17:46:51 +0000
3+++ addons/openerp/controllers/search.py 2011-02-18 08:55:33 +0000
4@@ -25,8 +25,6 @@
5 from error_page import _ep
6 from openobject import rpc
7 from openobject.tools import expose, ast
8-import simplejson
9-
10
11 class Search(Form):
12
13@@ -337,7 +335,7 @@
14 if not custom_domains:
15 custom_domains = []
16 else:
17- custom_domains = simplejson.loads(custom_domains)
18+ custom_domains = ast.literal_eval(custom_domains)
19
20 # conversion of the pseudo domain from the javascript to a valid domain
21 ncustom_domain = []
22
23=== modified file 'addons/openerp/static/javascript/search.js'
24--- addons/openerp/static/javascript/search.js 2011-02-17 16:05:42 +0000
25+++ addons/openerp/static/javascript/search.js 2011-02-18 08:55:33 +0000
26@@ -271,7 +271,7 @@
27 function display_Customfilters(all_domains, group_by_ctx) {
28 var Allrecords = {};
29 var error = false;
30- jQuery('tbody',idSelector('filter_option_table')).each(function () {
31+ jQuery('tbody:visible',idSelector('filter_option_table')).each(function () {
32 var record = {};
33 var pid = jQuery(this).index();
34
35@@ -285,11 +285,11 @@
36 rec[$fieldname.attr('value')] = $constraint_value.val();
37 record[id] = rec;
38 } else {
39- $constraint_value.addClass('errorfield').val(_('Invalid Value')).click(function() {
40- jQuery(this).val('').removeClass('errorfield')
41- })
42- error = true;
43- }
44+ $constraint_value.addClass('errorfield').val(_('Invalid Value')).click(function() {
45+ jQuery(this).val('').removeClass('errorfield')
46+ })
47+ error = true;
48+ }
49 });
50
51 if (jQuery.keys(record).length != 0){
52@@ -360,9 +360,6 @@
53 if (isOrderable(type)) {
54 comparison = (comparison == 'ilike' ? '=' : '!=');
55 }
56- else {
57- value = '%' + value + '%';
58- }
59 break;
60 case '<':
61 case '>':