[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
This commit is contained in:
Nicolas Martinelli
2018-12-06 12:50:00 +00:00
parent 77e7d952b4
commit 66704d3d1f
+1 -1
View File
@@ -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'])