From 43497d51f437f9dcbccc8193b738e143da4cb285 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Fri, 22 Feb 2019 09:13:12 +0000 Subject: [PATCH] [IMP] delivery: margin set on carrier from int to float Some customers need to have a float instead of a in for the percentage of the margin taken on the delivery. So we modified the integer value into a float. --- addons/delivery/models/delivery_carrier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/delivery/models/delivery_carrier.py b/addons/delivery/models/delivery_carrier.py index d12344780f4..1e48c8079a9 100644 --- a/addons/delivery/models/delivery_carrier.py +++ b/addons/delivery/models/delivery_carrier.py @@ -56,7 +56,7 @@ class DeliveryCarrier(models.Model): zip_from = fields.Char('Zip From') zip_to = fields.Char('Zip To') - margin = fields.Integer(help='This percentage will be added to the shipping price.') + margin = fields.Float(help='This percentage will be added to the shipping price.') free_over = fields.Boolean('Free if order amount is above', help="If the order total amount (shipping excluded) is above or equal to this value, the customer benefits from a free shipping", default=False, oldname='free_if_more_than') amount = fields.Float(string='Amount', help="Amount of the order to benefit from a free shipping, expressed in the company currency") @@ -147,7 +147,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'] = float(res['price']) * (1.0 + (float(self.margin) / 100.0)) + res['price'] = float(res['price']) * (1.0 + (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'])