From d236da5b4e695a7dc54a98b2577c89b25b0a1fd2 Mon Sep 17 00:00:00 2001 From: Pierre Masereel <pim@odoo.com> Date: Mon, 2 Oct 2017 13:40:20 +0200 Subject: [PATCH] [FIX] point_of_sale: scale weight and price with pricelists Since pricelist have been added in POS, the price was not correctly set in the scale screen. We also reduced the ferquency we call the posbox to get the scale weight, because we requested it every 150ms, and the posbox requests only every 500 ms to the scale --- addons/point_of_sale/static/src/js/screens.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 8860236ba133..5aef8f92d264 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -281,12 +281,22 @@ var ScaleScreenWidget = ScreenWidget.extend({ return self.pos.proxy.scale_read().then(function(weight){ self.set_weight(weight.weight); }); - },{duration:150, repeat: true}); + },{duration:500, repeat: true}); }, get_product: function(){ return this.gui.get_current_screen_param('product'); }, + _get_active_pricelist: function(){ + var current_order = this.pos.get_order(); + var current_pricelist = this.pos.default_pricelist; + + if (current_order) { + current_pricelist = current_order.pricelist; + } + + return current_pricelist; + }, order_product: function(){ this.pos.get_order().add_product(this.get_product(),{ quantity: this.weight }); }, @@ -296,7 +306,8 @@ var ScaleScreenWidget = ScreenWidget.extend({ }, get_product_price: function(){ var product = this.get_product(); - return (product ? product.price : 0) || 0; + var pricelist = this._get_active_pricelist(); + return (product ? product.get_price(pricelist, this.weight) : 0) || 0; }, get_product_uom: function(){ var product = this.get_product(); -- GitLab