61 lines
2.1 KiB
JavaScript
61 lines
2.1 KiB
JavaScript
odoo.define('product_library', function (require) {
|
|
|
|
"use strict";
|
|
var db = require("point_of_sale.DB");
|
|
db.include({
|
|
|
|
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;
|
|
}
|
|
*/
|
|
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;
|
|
|
|
});
|