summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-12-06 12:48:00 +0000
committerNicolas Martinelli <nim@odoo.com>2018-12-06 12:50:00 +0000
commit66704d3d1f193884d3ee2de85dccda54ee144aa2 (patch)
treef305e0ee92662f5bf1ef615a80ab25d45785375e
parent77e7d952b4c72d58c1b8f34b57e355f5b98c88b0 (diff)
[FIX] delivery: cast to float
Some providers (e.g. Fedex) return a `decimal.Decimal` instead of a `float`, which causes a crash. opw-1903784 closes odoo/odoo#29311
-rw-r--r--addons/delivery/models/delivery_carrier.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/delivery/models/delivery_carrier.py b/addons/delivery/models/delivery_carrier.py
index d1e76fae927..7ac9bb8af86 100644
--- a/addons/delivery/models/delivery_carrier.py
+++ b/addons/delivery/models/delivery_carrier.py
@@ -119,7 +119,7 @@ class DeliveryCarrier(models.Model):
if hasattr(self, '%s_rate_shipment' % self.delivery_type):
res = getattr(self, '%s_rate_shipment' % self.delivery_type)(order)
# apply margin on computed price
- res['price'] = res['price'] * (1.0 + (float(self.margin) / 100.0))
+ res['price'] = float(res['price']) * (1.0 + (float(self.margin) / 100.0))
# free when order is large enough
if res['success'] and self.free_over and order._compute_amount_total_without_delivery() >= self.amount:
res['warning_message'] = _('Info:\nThe shipping is free because the order amount exceeds %.2f.\n(The actual shipping cost is: %.2f)') % (self.amount, res['price'])