From 10046d854c9973c23208073b21ab95725981ec7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Mon, 28 Apr 2014 17:33:26 +0200 Subject: [PATCH] [IMP] point_of_sale: use the product unit's precision for rounding the weight bzr revid: fva@openerp.com-20140428153326-klgddc93ud9t0uqr --- addons/point_of_sale/static/src/js/screens.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index c58e7d860a0..71fdb3a5609 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -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();