[FIX] OPW 574218: many2one: do not prefilter records when user click on 'Search More' with empty text

- Normally when user click on 'Search More' on many2one fields, relation
   object records are prefiltered based on the text user entered in the
   many2one field.
       But if user do not enter any text before click on 'Search More',
   system will call name_search() with an empty search criteria - and
   this could be quite expensive depending on the size of the dataset!.
   (this of name_search() on more that 10.000 products...)
   
   We now do not prefilter records if search value is empty (standard domain
   filtering still apply).

bzr revid: xal@openerp.com-20120525131416-ie958wu0cihjslgc
This commit is contained in:
Xavier ALT
2012-05-25 15:14:16 +02:00
parent 6379e7899c
commit 27c16a7721
+13 -4
View File
@@ -2056,11 +2056,20 @@ openerp.web.form.FieldMany2One = openerp.web.form.Field.extend({
if (values.length > self.limit) {
values = values.slice(0, self.limit);
values.push({label: _t("<em>   Search More...</em>"), action: function() {
dataset.name_search(search_val, self.build_domain(), 'ilike'
, false, function(data) {
if (search_val.length == 0) {
// search optimisation - in case user didn't enter any text we
// do not need to prefilter records; for big datasets (ex: more
// that 10.000 records) calling name_search() could be very very
// expensive!
self._change_int_value(null);
self._search_create_popup("search", data);
});
self._search_create_popup("search", undefined);
} else {
dataset.name_search(search_val, self.build_domain(), 'ilike'
, false, function(data) {
self._change_int_value(null);
self._search_create_popup("search", data);
});
}
}});
}
// quick create