From 4ad547aeca8a833c483de3decec9fdc7ca47268d Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Fri, 20 Nov 2020 08:40:06 +0000 Subject: [PATCH] [FIX] delivery: shipping cost free if above amount A based on rules shipping method with the "Free if order amount is above" field enabled is not correctly applied. To reproduce the error: (Need website_sale) 1. Go to Settings > Website 2. Enable "Shipping Costs" 3. Go to Website > Configuration > eCommerce > Shipping Methods 4. Create a new one - Select "Based on Rules" - Enable "Free if order amount is above" - Set the corresponding amount - In pricing, add a line 5. Save & Publish (Click on "Unpublished") 6. Go to website's shop 7. Add the product set in the shipping method to your cart - Select an amount sufficient to exceed the threshold amount set in step 4 8. Process Checkout => The shipping method is shown, but the associated amount is "No price rule matching this order[...]" The shipping method price should be 0. (This error also happens when creating a SO) OPW-2383258 closes odoo/odoo#62290 X-original-commit: 393b7ad7b7dff1cbf830374c76ef0a681a71be6a Signed-off-by: adwid --- addons/delivery/models/delivery_grid.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/delivery/models/delivery_grid.py b/addons/delivery/models/delivery_grid.py index 9df02ea297c..cee239daec4 100644 --- a/addons/delivery/models/delivery_grid.py +++ b/addons/delivery/models/delivery_grid.py @@ -97,6 +97,8 @@ class ProviderGrid(models.Model): price = 0.0 criteria_found = False price_dict = {'price': total, 'volume': volume, 'weight': weight, 'wv': volume * weight, 'quantity': quantity} + if self.free_over and total >= self.amount: + return 0 for line in self.price_rule_ids: test = safe_eval(line.variable + line.operator + str(line.max_value), price_dict) if test: