From 0e2919d1eb2b6cbd356de6da6de948fe9d1fd011 Mon Sep 17 00:00:00 2001 From: santiky Date: Sun, 22 Aug 2021 17:24:44 +0200 Subject: [PATCH] =?UTF-8?q?Arregla=20b=C3=BAsqueda=20en=20el=20TPV.=20No?= =?UTF-8?q?=20encuentra=20art=C3=ADculos=20introduciendo=20tildes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product_library/__init__.py~ | 23 ------ product_library/__manifest__.py~ | 28 ------- product_library/static/src/js/db.js | 78 ++++++++++++------- .../static/src/js/product_library.js | 2 +- 4 files changed, 52 insertions(+), 79 deletions(-) delete mode 100644 product_library/__init__.py~ delete mode 100644 product_library/__manifest__.py~ diff --git a/product_library/__init__.py~ b/product_library/__init__.py~ deleted file mode 100644 index 1f2b627..0000000 --- a/product_library/__init__.py~ +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2013-Today OpenERP SA (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import models -#import controllers diff --git a/product_library/__manifest__.py~ b/product_library/__manifest__.py~ deleted file mode 100644 index 2169b32..0000000 --- a/product_library/__manifest__.py~ +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -{ - 'name': 'Product Library', - 'category': 'Product', - 'summary': 'Add library related fields to product', - 'version': '0.1', - 'description': """ - -Add several fields to product for libraries -================================================== -Autor, coleccion, ISBN,.... - -""", - 'author': 'Criptomart', - 'depends': [ - 'product', - 'point_of_sale', - ], - 'data': [ - 'views/product.xml', - 'views/templates.xml' - ], - 'demo': [], - 'installable': True, - 'auto_install': False, - 'application': True, -} diff --git a/product_library/static/src/js/db.js b/product_library/static/src/js/db.js index 7b6983a..1194dec 100644 --- a/product_library/static/src/js/db.js +++ b/product_library/static/src/js/db.js @@ -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; - }); +}); diff --git a/product_library/static/src/js/product_library.js b/product_library/static/src/js/product_library.js index a932ef0..525fb37 100644 --- a/product_library/static/src/js/product_library.js +++ b/product_library/static/src/js/product_library.js @@ -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');