[FIX] point_of_sale: float comparison
- Create the following pricelist for product A: 4 Units: 2.88 3 Units: 3.45 2 Units: 4.85 1 Units: 7.50 - In the POS, click several time on A to add in the cart The 2 first units are merged in a single line, but from the third one a new line is created. This is because of the float reproesentation of 4.85, which becomes 4.8500000000000005. opw-1887586 closes odoo/odoo#27539
This commit is contained in:
@@ -1508,6 +1508,7 @@ exports.Orderline = Backbone.Model.extend({
|
||||
// when we add an new orderline we want to merge it with the last line to see reduce the number of items
|
||||
// in the orderline. This returns true if it makes sense to merge the two
|
||||
can_be_merged_with: function(orderline){
|
||||
var price = parseFloat(round_di(this.price || 0, this.pos.dp['Product Price']).toFixed(this.pos.dp['Product Price']));
|
||||
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){
|
||||
@@ -1516,7 +1517,7 @@ exports.Orderline = Backbone.Model.extend({
|
||||
return false;
|
||||
}else if(this.get_discount() > 0){ // we don't merge discounted orderlines
|
||||
return false;
|
||||
}else if(this.price !== orderline.get_product().get_price(orderline.order.pricelist, this.get_quantity())){
|
||||
}else if(price !== orderline.get_product().get_price(orderline.order.pricelist, this.get_quantity())){
|
||||
return false;
|
||||
}else if(this.product.tracking == 'lot') {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user