[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 <adwid@users.noreply.github.com>
This commit is contained in:
Adrien Widart
2020-11-25 08:06:09 +00:00
parent 20141a0b91
commit 4ad547aeca
+2
View File
@@ -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: