Browse Source

Normalize accented chars. in product search

pull/488/head
François Kawala 5 years ago
parent
commit
c0de757d63
  1. 1
      pos_accented_search/__init__.py
  2. 22
      pos_accented_search/__openerp__.py
  3. BIN
      pos_accented_search/static/description/icon.png
  4. 22
      pos_accented_search/static/src/js/db.js
  5. 10
      pos_accented_search/views/templates.xml

1
pos_accented_search/__init__.py

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

22
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',
],
}

BIN
pos_accented_search/static/description/icon.png

After

Width: 1571  |  Height: 1690  |  Size: 90 KiB

22
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;
});

10
pos_accented_search/views/templates.xml

@ -0,0 +1,10 @@
<odoo>
<data>
<template id="assets_backend" name="pos_accented_search" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_accented_search/static/src/js/db.js"></script>
</xpath>
</template>
</data>
</odoo>
Loading…
Cancel
Save