Arregla búsqueda en el TPV.
No encuentra artículos introduciendo tildes.
This commit is contained in:
parent
f93bc37942
commit
0e2919d1eb
4 changed files with 52 additions and 79 deletions
|
@ -1,37 +1,61 @@
|
|||
odoo.define('product_library', function (require) {
|
||||
odoo.define('product_library', function (require) {
|
||||
|
||||
"use strict";
|
||||
var db = require("point_of_sale.DB");
|
||||
db.include({
|
||||
|
||||
_product_search_string: function(product){
|
||||
var str = product.display_name;
|
||||
if(product.default_code){
|
||||
str += '|' + product.default_code;
|
||||
}
|
||||
if(product.autor){
|
||||
str += '|' + product.autor;
|
||||
}
|
||||
if(product.genero){
|
||||
str += '|' + product.genero;
|
||||
}
|
||||
if(product.editorial){
|
||||
str += '|' + product.editorial;
|
||||
}
|
||||
str += '|' + product.description;
|
||||
normalize_characters: function (product) {
|
||||
// The normalization extract out combining diacritical marks
|
||||
// All those diacritics in range [\u0300-\u036f].
|
||||
// See https://en.wikipedia.org/wiki/Combining_Diacritical_Marks.
|
||||
// All the diacritics are removed by the code below.
|
||||
return product.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.replace(/[\u0152-\u0153]/g, "oe");
|
||||
},
|
||||
|
||||
add_custom_fields: function(product) {
|
||||
if(product) {
|
||||
var str = product.display_name;
|
||||
if(product.default_code){
|
||||
str += '|' + product.default_code;
|
||||
}
|
||||
if(product.autor){
|
||||
str += '|' + product.autor;
|
||||
}
|
||||
if(product.genero){
|
||||
str += '|' + product.genero;
|
||||
}
|
||||
if(product.editorial){
|
||||
str += '|' + product.editorial;
|
||||
}
|
||||
/*
|
||||
if (product.description) {
|
||||
str += '|' + product.description;
|
||||
}
|
||||
if (product.description_sale) {
|
||||
str += '|' + product.description_sale;
|
||||
}
|
||||
if (product.description) {
|
||||
str += '|' + product.description;
|
||||
}
|
||||
if (product.description_sale) {
|
||||
str += '|' + product.description_sale;
|
||||
}
|
||||
*/
|
||||
str = product.id + ':' + str.replace(':','') + '\n';
|
||||
str = product.id + ':' + str.replace(':','') + '\n';
|
||||
}
|
||||
return str;
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
_product_search_string: function(product) {
|
||||
console.log("product : " + JSON.stringify(product, null, 4));
|
||||
var str = this.add_custom_fields(product);
|
||||
console.log("string : " + str);
|
||||
var norm = this.normalize_characters(str);
|
||||
console.log("normalizado : " + norm);
|
||||
return norm;
|
||||
},
|
||||
/*
|
||||
search_product_in_category: function (category_id, query) {
|
||||
return this._super(category_id, this.add_custom_fields(query));
|
||||
},*/
|
||||
});
|
||||
|
||||
return db;
|
||||
return db;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ Overload models.PosModel
|
|||
this.member_categories = [];
|
||||
|
||||
var product_model = _.find(this.models, function(model){ return model.model === 'product.product'; });
|
||||
product_model.fields.push('default_code');
|
||||
//product_model.fields.push('default_code');
|
||||
product_model.fields.push('autor');
|
||||
product_model.fields.push('editorial');
|
||||
product_model.fields.push('genero');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue