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.

49 lines
1.9 KiB

  1. /* Copyright 2018 Akretion - Raphaël Reverdy
  2. License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
  3. odoo.define("pos_fix_search_limit.db", function (require) {
  4. "use strict";
  5. var PosDB = require("point_of_sale.DB");
  6. PosDB.include({
  7. limit: 314159265, // the maximum number of results returned by a search
  8. });
  9. });
  10. odoo.define('pos_fix_search_limit.product_list', function(require) {
  11. "use strict";
  12. var screens = require('point_of_sale.screens');
  13. var core = require('web.core');
  14. var qweb = core.qweb;
  15. screens.ProductListWidget.include({
  16. displayLimit: 100, //number of elements displayed
  17. renderElement: function() {
  18. //Limit the number of elements to displayLimit (instead of db.limit)
  19. // (db.limit has been increased to return more results)
  20. // (but we still want to limit the display)
  21. //And make use of document fragment, because better perfs
  22. var self = this;
  23. var i = 0;
  24. var len = Math.min(this.product_list.length, this.displayLimit);
  25. var frag = document.createDocumentFragment();
  26. var product_node = null;
  27. var el_str = qweb.render(this.template, {widget: this});
  28. var el_node = document.createElement('div');
  29. el_node.innerHTML = el_str;
  30. el_node = el_node.childNodes[1];
  31. if(this.el && this.el.parentNode){
  32. this.el.parentNode.replaceChild(el_node,this.el);
  33. }
  34. this.el = el_node;
  35. var list_container = el_node.querySelector('.product-list');
  36. for(i=0; i < len; i++){
  37. product_node = this.render_product(this.product_list[i]);
  38. product_node.addEventListener('click',this.click_product_handler);
  39. frag.appendChild(product_node);
  40. }
  41. list_container.appendChild(frag);
  42. }
  43. });
  44. });