From 6c01d2bc0baeb7a0899e61a889f30b045499b571 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Wed, 23 Aug 2023 13:54:15 +0200 Subject: [PATCH] [FIX] website_event_sale: clear cart element in the session Steps to reproduce: ------------------- - create and pay with ewallet a cart with a ticket; - create and pay with ewallet an other cart with a ticket; Remark: Don't clear element in the session like 'sale_order_id', etc. For example, by moving the mouse over the cart or by making a payment process. Issue: ------ An error is raised with the message: "It is forbidden to modify a sales order which is not in draft status.". Cause: ------ We apply an update to the cart on a sale order which is not in draft. Solution: --------- Make sure we are working on a sale order in draft when applying a registration post. If not, clear session elements. opw-3465937 closes odoo/odoo#133825 X-original-commit: 22f652ddb85de065208371aa21fed8c674687063 Signed-off-by: Thomas Lefebvre (thle) --- addons/website_event_sale/controllers/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/website_event_sale/controllers/main.py b/addons/website_event_sale/controllers/main.py index 99624cba6e9..8f776b795fd 100644 --- a/addons/website_event_sale/controllers/main.py +++ b/addons/website_event_sale/controllers/main.py @@ -31,6 +31,9 @@ class WebsiteEventSaleController(WebsiteEventController): return super()._create_attendees_from_registration_post(event, registration_data) order_sudo = request.website.sale_get_order(force_create=True) + if order_sudo.state != 'draft': + request.website.sale_reset() + order_sudo = request.website.sale_get_order(force_create=True) tickets_data = defaultdict(int) for data in registration_data: