You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
942 B

  1. odoo.define('pos_accented_search', function (require) {
  2. "use strict";
  3. var db = require("point_of_sale.DB");
  4. db.include({
  5. normalize_characters: function (product) {
  6. // The normalization extract out combining diacritical marks
  7. // All those diacritics in range [\u0300-\u036f].
  8. // See https://en.wikipedia.org/wiki/Combining_Diacritical_Marks.
  9. // All the diacritics are removed by the code below.
  10. return product.normalize("NFD")
  11. .replace(/[\u0300-\u036f]/g, "")
  12. .replace(/[\u0152-\u0153]/g, "oe");
  13. },
  14. _product_search_string: function (product) {
  15. return this.normalize_characters(this._super(product));
  16. },
  17. search_product_in_category: function (category_id, query) {
  18. return this._super(category_id, this.normalize_characters(query));
  19. },
  20. });
  21. return db;
  22. });