[FIX] point_of_sale: coherent image url handling

bzr revid: fva@openerp.com-20120910154828-4k699hi3lu8lgxvu
This commit is contained in:
Frédéric van der Essen 2012-09-10 17:48:28 +02:00
parent 9f6786c139
commit 83fc106eaa
4 changed files with 9 additions and 16 deletions

View File

@ -48,7 +48,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
'units': null,
'units_by_id': null,
'selectedOrder': undefined,
'selectedOrder': null,
});
this.get('orders').bind('remove', function(){ self.on_removed_order(); });
@ -310,6 +310,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
});
module.Product = Backbone.Model.extend({
get_image_url: function(){
return '/web/binary/image?session_id='instance.session.session_id+'&model=product.product&field=image&id='+this.get('id');
},
});
module.ProductCollection = Backbone.Collection.extend({
@ -339,7 +342,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
get_discount: function(){
return this.discount;
},
// FIXME
get_product_type: function(){
return this.type;
},

View File

@ -521,13 +521,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
var product = this.get_product();
return (product ? product.get('list_price') : 0) || 0;
},
get_product_image_url: function() {
var product = this.get_product();
if(!product){
return "";
}
return '/web/binary/image?session_id='+instance.session.session_id+'&model=product.product&field=image&id='+product.get('id');
},
get_product_weight: function(){
return this.weight || 0;
},

View File

@ -284,12 +284,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this.click_product_action = options.click_product_action;
},
// returns the url of the product thumbnail
get_image_url: function() {
return '/web/binary/image?session_id='+instance.session.session_id+'&model=product.product&field=image&id='+this.model.get('id');
},
renderElement: function() {
this._super();
this.$('img').replaceWith(this.pos_widget.image_cache.get_image(this.get_image_url()));
this.$('img').replaceWith(this.pos_widget.image_cache.get_image(this.model.get_image_url()));
var self = this;
$("a", this.$el).click(function(e){
if(self.click_product_action){

View File

@ -185,8 +185,8 @@
<span class="product-price">
<t t-esc="widget.format_currency(widget.get_product_price()) + '/Kg'" />
</span>
<t t-if="widget.get_product_image_url()">
<img t-att-src="widget.get_product_image_url()" />
<t t-if="widget.get_product()">
<img t-att-src="widget.get_product().get_image_url()" />
</t>
</div>
</div>
@ -346,7 +346,8 @@
<t t-name="ErrorPopupWidget">
<div class="modal-dialog">
<div class="popup popup-help">
<p class="message"><t t-esc=" widget.message || 'Product not Found' " /></p>
<p class="message"><t t-esc=" widget.message || 'Error' " /></p>
<p class="comment"><t t-esc=" widget.comment || '' "/></p>
</div>
</div>
</t>