[IMP] point_of_sale: use the product unit's precision for rounding the weight
authorFrédéric van der Essen <fva@openerp.com>
Mon, 28 Apr 2014 15:33:26 +0000 (17:33 +0200)
committerFrédéric van der Essen <fva@openerp.com>
Mon, 28 Apr 2014 15:33:26 +0000 (17:33 +0200)
bzr revid: fva@openerp.com-20140428153326-klgddc93ud9t0uqr

addons/point_of_sale/static/src/js/screens.js

index c58e7d8..71fdb3a 100644 (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();