diff --git a/pos_default_empty_image/__manifest__.py b/pos_default_empty_image/__manifest__.py index e2583aac..eb2ae81f 100644 --- a/pos_default_empty_image/__manifest__.py +++ b/pos_default_empty_image/__manifest__.py @@ -1,13 +1,12 @@ -# -*- coding: utf-8 -*- # © 2015 Akretion, GRAP, OCA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'POS Default empty image', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Point Of Sale', 'summary': 'Optimize loading time for products without image', 'author': "Akretion, GRAP, Odoo Community Association (OCA)", - 'website': "https://akretion.com", + 'website': "https://www.github.com/OCA/pos", 'license': 'AGPL-3', 'depends': [ 'point_of_sale', diff --git a/pos_default_empty_image/models/product_product.py b/pos_default_empty_image/models/product_product.py index 8350fa70..0cb6f822 100644 --- a/pos_default_empty_image/models/product_product.py +++ b/pos_default_empty_image/models/product_product.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2017 - Today: # GRAP (http://www.grap.coop) # Akretion (http://www.akretion.com) @@ -15,7 +14,7 @@ class ProductProduct(models.Model): @api.depends('image') def _compute_has_image(self): for product in self: - product.has_image = product.image is not False + product.has_image = product.image has_image = fields.Boolean( compute='_compute_has_image', string='Has Image', store=True) diff --git a/pos_default_empty_image/static/src/js/db.js b/pos_default_empty_image/static/src/js/db.js deleted file mode 100644 index 8615de67..00000000 --- a/pos_default_empty_image/static/src/js/db.js +++ /dev/null @@ -1,17 +0,0 @@ -odoo.define('pos_default_empty_image.db', function (require) { - "use strict"; - - var models = require('point_of_sale.models'); - - var _super_posmodel = models.PosModel.prototype; - - // load new field 'has_image' for 'product.product' model - models.PosModel = models.PosModel.extend({ - initialize: function (session, attributes) { - var product_model = _.find(this.models, function(model){ return model.model === 'product.product'; }); - product_model.fields.push('has_image'); - - return _super_posmodel.initialize.call(this, session, attributes); - }, - }); -}); diff --git a/pos_default_empty_image/static/src/js/models.js b/pos_default_empty_image/static/src/js/models.js new file mode 100644 index 00000000..344022b1 --- /dev/null +++ b/pos_default_empty_image/static/src/js/models.js @@ -0,0 +1,8 @@ +odoo.define('pos_default_empty_image.db', function (require) { + "use strict"; + + var models = require('point_of_sale.models'); + + // load new field 'has_image' for 'product.product' model + models.load_fields("product.product", ['has_image']); +}); diff --git a/pos_default_empty_image/static/src/js/widgets.js b/pos_default_empty_image/static/src/js/widgets.js index baa6187e..1dc43d9f 100644 --- a/pos_default_empty_image/static/src/js/widgets.js +++ b/pos_default_empty_image/static/src/js/widgets.js @@ -20,16 +20,19 @@ odoo.define('pos_default_empty_image.widgets', function (require) { return this._super(product); } else { - var cached = this.product_cache.get_node(product.id); + var current_pricelist = this._get_active_pricelist(); + var cache_key = this.calculate_cache_key(product, current_pricelist); + var cached = this.product_cache.get_node(cache_key); if(!cached){ var product_html = QWeb.render('ProductNoImage',{ widget: this, product: product, + pricelist: current_pricelist, }); var product_node = document.createElement('div'); product_node.innerHTML = product_html; product_node = product_node.childNodes[1]; - this.product_cache.cache_node(product.id,product_node); + this.product_cache.cache_node(cache_key,product_node); return product_node; } return cached; diff --git a/pos_default_empty_image/static/src/xml/pos_default_empty_image.xml b/pos_default_empty_image/static/src/xml/pos_default_empty_image.xml index 46060953..a76a07c5 100644 --- a/pos_default_empty_image/static/src/xml/pos_default_empty_image.xml +++ b/pos_default_empty_image/static/src/xml/pos_default_empty_image.xml @@ -1,23 +1,22 @@ - +
- + - +
-
+
- +
- diff --git a/pos_default_empty_image/views/templates.xml b/pos_default_empty_image/views/templates.xml index 8df12918..3cb6d9c4 100644 --- a/pos_default_empty_image/views/templates.xml +++ b/pos_default_empty_image/views/templates.xml @@ -2,7 +2,7 @@