From 541b082d84a861ee301e3cec67dae010842af8d0 Mon Sep 17 00:00:00 2001 From: Walid Date: Tue, 23 Jan 2024 11:19:27 +0100 Subject: [PATCH] [FIX] website_sale_delivery: do not check delivery for only services Steps to reproduce: - Setup easypost delivery - Create a service product and publish it on the website - Add that product alone to the cart and proceed to payment Bug: Error raised because total weight of the order is null Fix: no delivery will be created so we should skip the check if no deliverable product is present on the order note: on "_get_shop_payment_errors" switched the order to short circuit "_get_delivery_methods" opw-3647420 closes odoo/odoo#150735 X-original-commit: 3108339921dd7af65daacf60dc0104713116557b Signed-off-by: Walid Hanniche (waha) --- addons/website_sale/controllers/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 9b79f5e2938..d11e2019ccc 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -1722,10 +1722,9 @@ class WebsiteSale(payment_portal.PaymentPortal): :return: A list of errors (error_title, error_message) :rtype: list[tuple] """ - has_storable_products = any(line.product_id.type in ['consu', 'product'] for line in order.order_line) errors = [] - if not order._get_delivery_methods() and has_storable_products: + if not order.only_services and not order._get_delivery_methods(): errors.append(( _('Sorry, we are unable to ship your order'), _('No shipping method is available for your current order and shipping address. ' @@ -1746,7 +1745,7 @@ class WebsiteSale(payment_portal.PaymentPortal): """ order = request.website.sale_get_order() - if order and (request.httprequest.method == 'POST' or not order.carrier_id): + if order and not order.only_services and (request.httprequest.method == 'POST' or not order.carrier_id): # Update order's carrier_id (will be the one of the partner if not defined) # If a carrier_id is (re)defined, redirect to "/shop/payment" (GET method to avoid infinite loop) carrier_id = post.get('carrier_id')