[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) <thle@odoo.com>
This commit is contained in:
Thomas Lefebvre (thle)
2023-09-01 05:53:43 +00:00
parent 2da41ec07b
commit 6c01d2bc0b
@@ -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: