Skip to content

Commit

Permalink
[FIX] tg_website_event_sale: не очищать корзину при выборе другого би…
Browse files Browse the repository at this point in the history
…лета, если в корзине позиция с отрицательой ценой

Такое воспроизводится при выборе Upgrade / Change ticket в модуле portal_event_tickets
  • Loading branch information
em230418 committed Dec 23, 2024
1 parent 81936a9 commit 3d5a4fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tg_website_event_sale/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Online Event Ticketing customizations for Tribal Gathering
============================================================

* Resets cart, when user registers in event in frontend
* Resets cart, when user registers in event in frontend.
Does not reset cart, if there are lines with negative price units (like refund line from portal_event_ticket)

* Makes event pages urls compatible for ``website_sale_affiliate`` features

Expand Down
16 changes: 14 additions & 2 deletions tg_website_event_sale/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@ class WebsiteEventSaleExtendController(WebsiteEventSaleController):
@route()
def registration_confirm(self, *args, **post):
order = request.website.sale_get_order(force_create=False)
if order and order.state in ("draft", "cancel"):
order.sudo().unlink()
if order:
if order.state == "draft":
SaleOrderLine = request.env["sale.order.line"].sudo()
discount_lines = SaleOrderLine.search(
[
("order_id", "=", order.id),
("price_unit", "<", 0),
("display_type", "=", False),
]
)
if not discount_lines:
order.sudo().unlink()
elif order.state == "cancel":
order.sudo().unlink()
return super().registration_confirm(*args, **post)

@route()
Expand Down

0 comments on commit 3d5a4fe

Please sign in to comment.