From 08138a332244c93e8d031151048e4e89f33d7e66 Mon Sep 17 00:00:00 2001 From: Ahmad Khanalizadeh Date: Tue, 12 Jul 2022 08:32:28 +0000 Subject: [PATCH] [FIX] point_of_sale: avoid rounding error when merging order lines Before this commit when multiple instances of the same product were selected in a PoS session, `can_be_merged_with` checked if they had the same price before merging them in a single order line. However the order line prices were not rounded. In the case of a floating point error in order line price calculation, this behavior resulted in multiple order lines for the same product. Steps to reproduce the issue: 1. Create a product 2. In the pricelist, create a formula of -10% discount based on cost, and set the cost as 136.35 $ 3. Open a POS session, add the product multiple times 4. The products are not combined in one group, each creates their own order line To fix this issue, we need to round the order line prices in this function. opw-2854304 closes odoo/odoo#96410 X-original-commit: 254521d302b31acd5b6f6cfbf49c184035b30eb0 Signed-off-by: Masereel Pierre --- addons/point_of_sale/static/src/js/models.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 3781a73e4ff..f8c90e08a62 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1668,7 +1668,7 @@ class Orderline extends PosModel { can_be_merged_with(orderline){ var price = parseFloat(round_di(this.price || 0, this.pos.dp['Product Price']).toFixed(this.pos.dp['Product Price'])); var order_line_price = orderline.get_product().get_price(orderline.order.pricelist, this.get_quantity()); - order_line_price = orderline.compute_fixed_price(order_line_price); + order_line_price = round_di(orderline.compute_fixed_price(order_line_price), this.pos.currency.decimal_places); if( this.get_product().id !== orderline.get_product().id){ //only orderline of the same product can be merged return false; }else if(!this.get_unit() || !this.get_unit().is_pos_groupable){