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.

42 lines
1.5 KiB

  1. odoo.define('pos_default_empty_image.widgets', function (require) {
  2. "use strict";
  3. var screens = require('point_of_sale.screens');
  4. var core = require('web.core');
  5. var QWeb = core.qweb;
  6. //don't try to get an image if we know the product ain't one
  7. var ProductListImageWidget = screens.ProductListWidget.include({
  8. get_product_image_url: function(product){
  9. if (product.has_image)
  10. return this._super(product);
  11. },
  12. // Change product display if product has no image;
  13. render_product: function(product){
  14. if (product.has_image){
  15. return this._super(product);
  16. }
  17. else {
  18. var current_pricelist = this._get_active_pricelist();
  19. var cache_key = this.calculate_cache_key(product, current_pricelist);
  20. var cached = this.product_cache.get_node(cache_key);
  21. if(!cached){
  22. var product_html = QWeb.render('ProductNoImage',{
  23. widget: this,
  24. product: product,
  25. pricelist: current_pricelist,
  26. });
  27. var product_node = document.createElement('div');
  28. product_node.innerHTML = product_html;
  29. product_node = product_node.childNodes[1];
  30. this.product_cache.cache_node(cache_key,product_node);
  31. return product_node;
  32. }
  33. return cached;
  34. }
  35. },
  36. });
  37. });