From 019c8b9975fc14fe1aba8c0d9e828917342aa96a Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 24 Apr 2018 11:32:24 +0200 Subject: [PATCH] [FIX] delivery: Wrong delivery costs on free_over = True The calculation of the delivery cost for a sale order / invoice was not correct when free over a limit had been satisfied. Steps to reproduce the bug: - Set a delivery method DM with a fixed price = 10.0 and free when the amount of the order exceeds 100 - Create a SO for an amount of 150 and set on it DM - Confirm the SO and deliver it Bug: A SO line with DM was created with a fixed price of 10.0 instead of 0.0 opw:1838070 --- addons/delivery/models/stock_picking.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index d66bab0d076..59fc0862656 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -161,6 +161,8 @@ class StockPicking(models.Model): def send_to_shipper(self): self.ensure_one() res = self.carrier_id.send_shipping(self)[0] + if self.carrier_id.free_over and self.sale_id._compute_amount_total_without_delivery() >= self.carrier_id.amount: + res['exact_price'] = 0.0 self.carrier_price = res['exact_price'] self.carrier_tracking_ref = res['tracking_number'] order_currency = self.sale_id.currency_id or self.company_id.currency_id