[FIX] website_sale_delivery: repr of floats

Following commit 340d70338f, 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
This commit is contained in:
Nicolas Martinelli
2018-03-29 12:14:56 +02:00
committed by Nicolas Martinelli
parent 285b045c64
commit 4c08b98c8a
@@ -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,