diff --git a/pos_default_empty_image/README.rst b/pos_default_empty_image/README.rst index 77c13d62..2623a082 100644 --- a/pos_default_empty_image/README.rst +++ b/pos_default_empty_image/README.rst @@ -6,59 +6,66 @@ POS Default Empty Image ======================= -In the point of sale, trying to load known inexistant images -is a waste of time. +This module extends the functionality of point of sale to make PoS load faster +and to improve products display. +Point Of Sale Load faster +------------------------- + +In the point of sale, trying to load known inexistant images is a waste of time. When you have 8000 products in your Point of Sale and most of them don't have images, you are happy to save thousands of useless requests: the POS load way faster. -Technical information -===================== - -Each time the pos instantiate a product, it will add an - +Improve products display +------------------------ -The browser will trigger as many requests than there is different url. +By default, Odoo PoS display a useless generic image for products that doesn't +have images. + .. figure:: /pos_default_empty_image/static/description/pos_display_default.png + :width: 800 px -If you have many products, the browser will soon reach his limit of -network connections to Odoo server and will wait for free slots instead of -loading other valuable contents. Then the POS is then very slow to work with. +With this module, the display of the product is changed, (Size of the name +is increased for better visibility); + .. figure:: /pos_default_empty_image/static/description/pos_display_improved.png + :width: 800 px -This module adds a field _has_image in product.template. +Technical information +===================== -If product has no image, the product image url is not sent to the POS +Each time the pos instantiate a product, it will add this code for each product -In the product list, the display of the product is changed, - (Size of the name is increased for better visibility); +.. code:: html -Indeed, if the product has an image, it will load normally. + -This module is compatible with pos_product_template +The browser will trigger as many requests than there are different urls. +If you have many products, the browser will soon reach his limit of +network connections to Odoo server and will wait for free slots instead of +loading other valuable contents. Then the POS is then very slow to work with. -Known issues -============ +This module adds a field has_image in product.product model. +If product has no image, the product image url is not sent to the POS Updates ======= * Feb 2016 : First version -* Feb 2017 : migration to v10 and improvements for Display - taken from - this module `pos_improve_images from GRAP - `_ for OpenERP 7. +* Feb 2017 : migration to v10 and improvements for Display Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here `_. +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. Credits @@ -69,6 +76,7 @@ Contributors * Hparfr `Akretion `_ * Sylvain LE GAL +* Invitu Maintainer diff --git a/pos_default_empty_image/models/__init__.py b/pos_default_empty_image/models/__init__.py index 9649db77..5c74c8c3 100644 --- a/pos_default_empty_image/models/__init__.py +++ b/pos_default_empty_image/models/__init__.py @@ -1 +1 @@ -from . import product +from . import product_product diff --git a/pos_default_empty_image/models/product.py b/pos_default_empty_image/models/product.py deleted file mode 100644 index 0a9344db..00000000 --- a/pos_default_empty_image/models/product.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# © <2015> -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import models, fields, api - - -class ProductTemplate(models.Model): - _inherit = 'product.template' - - @api.multi - def _get_has_image(self): - self.ensure_one() - self.has_image = self.image is not False - - has_image = fields.Boolean(compute='_get_has_image', string='Has Image') diff --git a/pos_default_empty_image/models/product_product.py b/pos_default_empty_image/models/product_product.py new file mode 100644 index 00000000..53f93a0f --- /dev/null +++ b/pos_default_empty_image/models/product_product.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © <2015> +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields, api + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + @api.multi + @api.depends('image') + def _compute_has_image(self): + for product in self: + product.has_image = product.image is not False + + has_image = fields.Boolean( + compute='_compute_has_image', string='Has Image', store=True) diff --git a/pos_default_empty_image/static/description/pos_display_default.png b/pos_default_empty_image/static/description/pos_display_default.png new file mode 100644 index 00000000..6974e40d Binary files /dev/null and b/pos_default_empty_image/static/description/pos_display_default.png differ diff --git a/pos_default_empty_image/static/description/pos_display_improved.png b/pos_default_empty_image/static/description/pos_display_improved.png new file mode 100644 index 00000000..0ec18e43 Binary files /dev/null and b/pos_default_empty_image/static/description/pos_display_improved.png differ diff --git a/pos_default_empty_image/static/src/css/pos_default_empty_image.css b/pos_default_empty_image/static/src/css/pos_default_empty_image.css index 3d88ab07..5452eabf 100644 --- a/pos_default_empty_image/static/src/css/pos_default_empty_image.css +++ b/pos_default_empty_image/static/src/css/pos_default_empty_image.css @@ -1,25 +1,8 @@ -/****************************************************************************** - Point Of Sale - Improve Images module for OpenERP - Copyright (C) 2014 GRAP (http://www.grap.coop) +/* + Copyright (C) 2014 - Today: GRAP (http://www.grap.coop) @author Julien WESTE - @author Sylvain LE GAL (https://twitter.com/legalsylvain) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -******************************************************************************/ - -/* - New display for 'product-img' and 'product-name' where there isn't image; + @author: Sylvain LE GAL (https://twitter.com/legalsylvain) + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */ .product-img-without-image{ diff --git a/pos_default_empty_image/static/src/js/db.js b/pos_default_empty_image/static/src/js/db.js new file mode 100644 index 00000000..8615de67 --- /dev/null +++ b/pos_default_empty_image/static/src/js/db.js @@ -0,0 +1,17 @@ +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/pos_default_empty_image.js b/pos_default_empty_image/static/src/js/widgets.js similarity index 72% rename from pos_default_empty_image/static/src/js/pos_default_empty_image.js rename to pos_default_empty_image/static/src/js/widgets.js index 15abc508..ab7c82b5 100644 --- a/pos_default_empty_image/static/src/js/pos_default_empty_image.js +++ b/pos_default_empty_image/static/src/js/widgets.js @@ -1,7 +1,6 @@ -odoo.define('pos_default_empty_image', function (require) { +odoo.define('pos_default_empty_image.widgets', function (require) { "use strict"; - var models = require('point_of_sale.models'); var screens = require('point_of_sale.screens'); var core = require('web.core'); @@ -38,14 +37,4 @@ odoo.define('pos_default_empty_image', function (require) { } }, }); - - var _super_posmodel = models.PosModel.prototype; - 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/views/templates.xml b/pos_default_empty_image/views/templates.xml index ce1ee79f..8df12918 100644 --- a/pos_default_empty_image/views/templates.xml +++ b/pos_default_empty_image/views/templates.xml @@ -2,7 +2,8 @@