[FIX] point_of_sale: faster UI search on products
In the POS interface, when searching through a large catalog of
products (~80000 in our test), the interface used to freeze for 5-10
seconds before returning search results.
After profiling the issue, we noticed that the unaccent'ing of product
names was done in the search loop.
Moving the unaccent outside the search loop (at product catalog
initialization) solves the issue.
We also change the timer before triggering a search: 70 ms after any
keypress is too short. In practice, this would trigger a search at every keypress.
200 ms appears to be a good compromise between UI interactivity and
saving useless computations
opw-2185087-rim
fixes 9ee9724a10
closes odoo/odoo#46040
X-original-commit: b5e01b48c32ad91e3e3df25917d035e36f97c6d2
Signed-off-by: Richard Mathot (rim) <rim@openerp.com>
This commit is contained in:
@@ -180,7 +180,7 @@ var PosDB = core.Class.extend({
|
||||
}
|
||||
for(var i = 0, len = products.length; i < len; i++){
|
||||
var product = products[i];
|
||||
var search_string = this._product_search_string(product);
|
||||
var search_string = utils.unaccent(this._product_search_string(product));
|
||||
var categ_id = product.pos_categ_id ? product.pos_categ_id[0] : this.root_category_id;
|
||||
product.product_tmpl_id = product.product_tmpl_id[0];
|
||||
if(!stored_categories[categ_id]){
|
||||
@@ -377,7 +377,7 @@ var PosDB = core.Class.extend({
|
||||
}
|
||||
var results = [];
|
||||
for(var i = 0; i < this.limit; i++){
|
||||
var r = re.exec(utils.unaccent(this.category_search_string[category_id]));
|
||||
var r = re.exec(this.category_search_string[category_id]);
|
||||
if(r){
|
||||
var id = Number(r[1]);
|
||||
results.push(this.get_product_by_id(id));
|
||||
|
||||
@@ -717,7 +717,7 @@ var ProductCategoriesWidget = PosBaseWidget.extend({
|
||||
|
||||
search_timeout = setTimeout(function(){
|
||||
self.perform_search(self.category, searchbox.value, event.which === 13);
|
||||
},70);
|
||||
},200);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user