diff --git a/pos_accented_search/__init__.py b/pos_accented_search/__init__.py new file mode 100644 index 00000000..7c68785e --- /dev/null +++ b/pos_accented_search/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/pos_accented_search/__openerp__.py b/pos_accented_search/__openerp__.py new file mode 100644 index 00000000..425bc871 --- /dev/null +++ b/pos_accented_search/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +{ + 'name': "pos_accented_search", + + 'summary': """ + Better product search in POS. Accented characters like é are normalized.""", + + 'description': """ + This add-on make pos product search insensitive to accented characters in the product + name. For instance, café will match both cafe and café. + """, + + 'author': "Le Nid", + 'website': "http://www.lenid.ch", + 'license': 'AGPL-3', + 'category': 'Point of Sale', + 'version': '0.1', + 'depends': ['point_of_sale'], + 'data': [ + 'views/templates.xml', + ], +} diff --git a/pos_accented_search/static/description/icon.png b/pos_accented_search/static/description/icon.png new file mode 100644 index 00000000..3e885187 Binary files /dev/null and b/pos_accented_search/static/description/icon.png differ diff --git a/pos_accented_search/static/src/js/db.js b/pos_accented_search/static/src/js/db.js new file mode 100644 index 00000000..89c23d39 --- /dev/null +++ b/pos_accented_search/static/src/js/db.js @@ -0,0 +1,22 @@ +odoo.define('pos_accented_search', function (require) { + + "use strict"; + var db = require("point_of_sale.DB"); + db.include({ + + remove_accented_characters: function(product){ + return product.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[\u0152-\u0153]/g, "oe") + }, + + _product_search_string: function(product){ + return this.remove_accented_characters(this._super(product)); + }, + + search_product_in_category: function(category_id, query){ + return this._super(category_id, this.remove_accented_characters(query)) + } + }); + + return db; + +}); diff --git a/pos_accented_search/views/templates.xml b/pos_accented_search/views/templates.xml new file mode 100644 index 00000000..bdf5ad31 --- /dev/null +++ b/pos_accented_search/views/templates.xml @@ -0,0 +1,10 @@ + + + + + +