Añade la funcionalidad de pos_empty_default_image pra poder mostraar el formato en productos sin imagen

This commit is contained in:
santiky 2021-08-23 23:03:12 +02:00
parent f1c8cf8414
commit 913de79db8
Signed by: snt
GPG key ID: A9FD34930EADBE71
14 changed files with 284 additions and 41 deletions

View file

@ -17,3 +17,23 @@
font-style: normal;
}
/*
Copyright (C) 2014 - Today: GRAP (http://www.grap.coop)
@author Julien WESTE
@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{
height:25px !important;
}
.product-name-without-image{
bottom:auto !important;
top:25px !important;
padding-top:3px !important;
height:80px !important;
line-height: 20px;
text-align: center;
word-wrap: break-word;
}

View file

@ -2,10 +2,12 @@ odoo.define('product_library.product_library', function (require) {
"use strict";
var models = require('point_of_sale.models');
var screens = require('point_of_sale.screens');
var core = require('web.core');
var gui = require('point_of_sale.gui');
var _t = core._t;
//var screens = require('point_of_sale.screens');
//var core = require('web.core');
//var gui = require('point_of_sale.gui');
//var _t = core._t;
models.load_fields("product.product", ['has_image']);
/* ********************************************************
Overload models.PosModel
@ -15,7 +17,7 @@ Overload models.PosModel
models.PosModel = models.PosModel.extend({
initialize: function (session, attributes) {
this.member_categories = [];
//this.member_categories = [];
var product_model = _.find(this.models, function(model){ return model.model === 'product.product'; });
//product_model.fields.push('default_code');

View file

@ -0,0 +1,42 @@
odoo.define('product_library.widgets', function (require) {
"use strict";
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);
},
// Change product display if product has no image;
render_product: function(product){
if (product.has_image){
return this._super(product);
}
else {
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(cache_key,product_node);
return product_node;
}
return cached;
}
},
});
});

View file

@ -26,4 +26,44 @@
</t>
</t>
<t t-name="ProductNoImage">
<article class='product' t-att-data-product-id="product.id" tabindex="0" t-attf-aria-labelledby="article_product_#{product.id}">
<t t-set="name_length" t-value="product.display_name.length" />
<t t-if='widget.pos.config.iface_fixed_font_size'>
<t t-set="font_size" t-value="widget.pos.config.iface_fixed_font_size" />
</t>
<t t-else="">
<t t-set="font_size" t-value="
name_length >=120 and 11
or name_length >=90 and 12
or name_length >=60 and 13
or name_length>=50 and 14
or name_length>=40 and 16
or 20"/>
</t>
<div class="product-img-without-image">
<t t-if="!product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(product.get_price(pricelist, 1),'Product Price')"/>
</span>
</t>
<t t-if="product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(product.get_price(pricelist, 1),'Product Price')+'/'+widget.pos.units_by_id[product.uom_id[0]].name"/>
</span>
</t>
<t t-if="product.formato">
<span class="format">
<t t-esc="product.formato"/>
</span>
</t>
</div>
<div class="product-name-without-image" t-attf-id="article_product_#{product.id}" t-attf-style="font-size: #{font_size}px !important; line-height: #{font_size}px !important;">
<t t-esc="product.display_name"/>
</div>
</article>
</t>
</templates>