[FIX] website_event: do not tell yet-to-come events are closed

Currently if an event has tickets, some of them with start date and some of
them without, it is considered has beginning at the minimal start date.
However if a ticket has no start date and is not expired, it means it is
available for sale.

An event start date is therefore the first date of its not expired tickets if
they all have a date, otherwise it is set to False (aka, already started).

We also fix display in main event page: events not yet open are not considered
as Sold out or Closed anymore, just not yet open.

Task ID 2244487
PR #51503

closes odoo/odoo#51523

X-original-commit: 8404a6ff12ee82e9b4ec35660f74dbe0b4a90cb0
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Thibault Delavallée
2020-05-19 10:14:41 +00:00
parent 8019738842
commit 5a5eced13c
2 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -265,8 +265,8 @@ class EventEvent(models.Model):
""" Compute the start sale date of an event. Currently lowest starting sale
date of tickets if they are used, of False. """
for event in self:
start_dates = [ticket.start_sale_date for ticket in event.event_ticket_ids if ticket.start_sale_date]
event.start_sale_date = min(start_dates) if start_dates else False
start_dates = [ticket.start_sale_date for ticket in event.event_ticket_ids if not ticket.is_expired]
event.start_sale_date = min(start_dates) if start_dates and all(start_dates) else False
@api.depends('event_ticket_ids.sale_available')
def _compute_event_registrations_sold_out(self):
@@ -235,10 +235,12 @@
</main>
</div>
<!-- Footer -->
<footer
t-attf-class="small align-self-end w-100 #{opt_events_list_cards and 'card-footer' or ((not opt_events_list_columns) and 'border-top mx-4 mt-auto pt-2' or 'border-top py-2')}">
<footer t-attf-class="small align-self-end w-100 #{opt_events_list_cards and 'card-footer' or ((not opt_events_list_columns) and 'border-top mx-4 mt-auto pt-2' or 'border-top py-2')}">
<span t-if="not event.event_registrations_open" class="text-danger">
<t t-if="event.event_registrations_sold_out">
<t t-if="event.start_sale_date and event.start_sale_date &gt; datetime.date.today()">
Registrations not yet open
</t>
<t t-elif="event.event_registrations_sold_out">
Sold Out
</t>
<t t-else="">