From 4c08b98c8a7ed43a6ef65f5a1eda9c0bb71901ec Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 29 Mar 2018 10:52:36 +0200 Subject: [PATCH] [FIX] website_sale_delivery: repr of floats Following commit 340d70338fb5796, we make sure the delivery price contains the right number of decimals by sending a formatted string instead of a float. Indeed, due to the float representation, values such as 25.310000000000002 may occur. opw-1831656 --- addons/website_sale_delivery/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/website_sale_delivery/controllers/main.py b/addons/website_sale_delivery/controllers/main.py index 36ee8bd651f..56ef9c451f2 100644 --- a/addons/website_sale_delivery/controllers/main.py +++ b/addons/website_sale_delivery/controllers/main.py @@ -4,6 +4,7 @@ from odoo import http, _ from odoo.http import request from odoo.addons.website_sale.controllers.main import WebsiteSale +from odoo.tools import float_repr class WebsiteSaleDelivery(WebsiteSale): @@ -60,12 +61,13 @@ class WebsiteSaleDelivery(WebsiteSale): def update_eshop_carrier(self, **post): order = request.website.sale_get_order() carrier_id = int(post['carrier_id']) + currency = order.currency_id if order: order._check_carrier_quotation(force_carrier_id=carrier_id) return {'status': order.delivery_rating_success, 'error_message': order.delivery_message, 'carrier_id': carrier_id, - 'new_amount_delivery': order.currency_id.round(order.delivery_price), + 'new_amount_delivery': float_repr(currency.round(order.delivery_price), currency.decimal_places), 'new_amount_untaxed': order.amount_untaxed, 'new_amount_tax': order.amount_tax, 'new_amount_total': order.amount_total,