[IMP] point_of_sale: use the product unit's precision for rounding the weight

bzr revid: fva@openerp.com-20140428153326-klgddc93ud9t0uqr
This commit is contained in:
Frédéric van der Essen 2014-04-28 17:33:26 +02:00
parent 1aaed44874
commit 10046d854c
1 changed files with 16 additions and 1 deletions

View File

@ -19,6 +19,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
var QWeb = instance.web.qweb,
_t = instance.web._t;
var round_pr = instance.web.round_precision
module.ScreenSelector = instance.web.Class.extend({
init: function(options){
this.pos = options.pos;
@ -564,7 +566,20 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.$('.js-weight').text(this.get_product_weight_string());
},
get_product_weight_string: function(){
return (this.weight || 0).toFixed(3) + ' Kg';
var product = this.get_product();
var defaultstr = (this.weight || 0).toFixed(3) + ' Kg';
if(!product || !this.pos){
return defaultstr;
}
var unit_id = product.uos_id || product.uom_id;
if(!unit_id){
return defaultstr;
}
var unit = this.pos.units_by_id[unit_id[0]];
var weight = round_pr(this.weight || 0, unit.rounding);
var weightstr = weight.toFixed(Math.ceil(Math.log(1.0/unit.rounding) / Math.log(10) ));
weightstr += ' Kg';
return weightstr;
},
get_product_image_url: function(){
var product = this.get_product();