Browse Source

[IMP] pos_default_empty_image courtesy @invitu

pull/351/head
Sylvain LE GAL 7 years ago
parent
commit
29dccd8e41
  1. 20
      pos_default_empty_image/README.rst
  2. 13
      pos_default_empty_image/__manifest__.py
  3. 1
      pos_default_empty_image/models/__init__.py
  4. 38
      pos_default_empty_image/static/src/css/pos_default_empty_image.css
  5. 31
      pos_default_empty_image/static/src/js/pos_default_empty_image.js
  6. 23
      pos_default_empty_image/static/src/xml/pos_default_empty_image.xml
  7. 3
      pos_default_empty_image/views/templates.xml

20
pos_default_empty_image/README.rst

@ -29,15 +29,17 @@ 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.
This module adds a field _has_image_ in product.template and will
change the product image url to his default placeholder directly in the POS.
This module adds a field _has_image in product.template.
Because there is only one url for this placeholder,
you will have only one request for all the products with no images.
If product has no image, the product image url is not sent to the POS
In the product list, the display of the product is changed,
(Size of the name is increased for better visibility);
Indeed, if the product has an image, it will load normally.
This module is compatible with pos_product_template
Known issues
============
@ -47,13 +49,16 @@ Updates
=======
* Feb 2016 : First version
* Feb 2017 : migration to v10 and improvements for Display - taken from
this module `pos_improve_images from GRAP
<https://github.com/grap/odoo-addons-grap/tree/7.0/pos_improve_images>`_ for OpenERP 7.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/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 <https://github.com/OCA/web/issues/new?body=module:%20pos_default_empty_image%0Aversion:%200.1%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/pos/issues/new?body=module:%20pos_default_empty_image%0Aversion:%200.1%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
@ -65,9 +70,6 @@ Contributors
* Hparfr <https://github.com/hparfr> `Akretion <https://akretion.com>`_
* Sylvain LE GAL <https://twitter.com/legalsylvain>
See also this module `pos_improve_images from GRAP
<https://github.com/grap/odoo-addons-grap/tree/7.0/pos_improve_images>`_ for OpenERP 7.
Maintainer
----------

13
pos_default_empty_image/__manifest__.py

@ -9,7 +9,14 @@
'author': "Akretion, GRAP, Odoo Community Association (OCA)",
'website': "https://akretion.com",
'license': 'AGPL-3',
'depends': ['point_of_sale'],
'data': ['view/view.xml'],
'qweb': [],
'depends': [
'point_of_sale',
],
'data': [
'views/templates.xml',
],
'qweb': [
'static/src/xml/pos_default_empty_image.xml',
],
'installable': True,
}

1
pos_default_empty_image/models/__init__.py

@ -0,0 +1 @@
from . import product

38
pos_default_empty_image/static/src/css/pos_default_empty_image.css

@ -0,0 +1,38 @@
/******************************************************************************
Point Of Sale - Improve Images module for OpenERP
Copyright (C) 2014 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 <http://www.gnu.org/licenses/>.
******************************************************************************/
/*
New display for 'product-img' and 'product-name' where there isn't image;
*/
.product-img-without-image{
height:25px !important;
}
.product-name-without-image{
bottom:auto !important;
top:25px !important;
padding-top:3px !important;
height:80px !important;
font-size: 24px !important;
line-height: 20px;
text-align: center;
word-wrap: break-word;
}

31
pos_default_empty_image/static/src/js/pos_default_empty_image.js

@ -1,17 +1,42 @@
odoo.define('pos_default_empty_image', function (require) {
"use strict";
"use strict";
var models = require('point_of_sale.models');
var screens = require('point_of_sale.screens');
var core = require('web.core');
var QWeb = core.qweb;
//don't try to get an image if we know the product ain't one
var ProductListImageWidget = screens.ProductListWidget.include({
get_product_image_url: function(product){
if (product.has_image)
return this._super(product);
},
return '/web/static/src/img/placeholder.png';
}
// Change product display if product has no image;
render_product: function(product){
if (product.has_image){
return this._super(product);
}
else {
var cached = this.product_cache.get_node(product.id);
if(!cached){
var image_url = this.get_product_image_url(product);
var product_html = QWeb.render('ProductNoImage',{
widget: this,
product: product,
});
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);
return product_node;
}
return cached;
}
},
});
var _super_posmodel = models.PosModel.prototype;

23
pos_default_empty_image/static/src/xml/pos_default_empty_image.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="ProductNoImage">
<span class='product' t-att-data-product-id="product.id">
<div class="product-img-without-image">
<t t-if="!product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(product.price,'Product Price')"/>
</span>
</t>
<t t-if="product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(product.price,'Product Price')+'/'+widget.pos.units_by_id[product.uom_id[0]].name"/>
</span>
</t>
</div>
<div class="product-name-without-image">
<t t-esc="product.display_name"/>
</div>
</span>
</t>
</templates>

3
pos_default_empty_image/views/view.xml → pos_default_empty_image/views/templates.xml

@ -4,5 +4,8 @@
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_default_empty_image/static/src/js/pos_default_empty_image.js"></script>
</xpath>
<xpath expr="//link[@id='pos-stylesheet']" position="after">
<link rel="stylesheet" href="/pos_default_empty_image/static/src/css/pos_default_empty_image.css"/>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save