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;
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();