diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2018-03-29 10:52:36 +0200 |
|---|---|---|
| committer | Nicolas Martinelli <nim-odoo@users.noreply.github.com> | 2018-03-29 12:14:56 +0200 |
| commit | 4c08b98c8a7ed43a6ef65f5a1eda9c0bb71901ec (patch) | |
| tree | d713470e493dc2b21a2ee2dbbb27a19492df9bac | |
| parent | 285b045c64565604e94b5c16534f02c7844c9489 (diff) | |
[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
| -rw-r--r-- | addons/website_sale_delivery/controllers/main.py | 4 |
1 files changed, 3 insertions, 1 deletions
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, |
