[FIX] event_sale, website_event_sale: treat edge case of 0 seats_max

When the max seats available is set to 0, there should not be a limit to
the seats available.

Previously this was not taken into account in the frontend event ticket
sale, so an event would appear to be sold out.

fixes #6999
opw-645542
This commit is contained in:
Nicolas Lempereur 2015-07-22 11:40:13 +02:00
parent caac19c102
commit c0e24fc9ce
2 changed files with 9 additions and 6 deletions

View File

@ -163,7 +163,10 @@ class event_event(osv.osv):
@api.one
@api.depends('event_ticket_ids.seats_max')
def _compute_seats_max(self):
self.seats_max = sum(ticket.seats_max for ticket in self.event_ticket_ids)
if any(ticket.seats_max == 0 for ticket in self.event_ticket_ids):
self.seats_max = 0
else:
self.seats_max = sum(ticket.seats_max for ticket in self.event_ticket_ids)
class event_ticket(osv.osv):
_name = 'event.event.ticket'

View File

@ -11,7 +11,7 @@
<template id="index" inherit_id="website_event.index" name="Event's Ticket">
<xpath expr="//li[@t-foreach='event_ids']/div/h4" position="before">
<t t-if="event.state in ['draft', 'confirm'] and event.event_ticket_ids">
<span t-if="not event.seats_available" class="label label-danger pull-right">Sold Out</span>
<span t-if="not event.seats_available and event.seats_max" class="label label-danger pull-right">Sold Out</span>
<span t-if="event.seats_available and event.seats_available &lt;= ((event.seats_max or 0) / 4)" class="label pull-right label-info">
Only <t t-esc="event.seats_available"/> Remaining
</span>
@ -66,16 +66,16 @@
</span>
</td>
<td>
<select t-if="ticket.seats_available" t-attf-name="ticket-#{ ticket.id }" class="form-control">
<t t-foreach="range(0, ticket.seats_available > 9 and 10 or ticket.seats_available+1 )" t-as="nb"><option t-esc="nb"/></t>
<select t-if="ticket.seats_available or not ticket.seats_max" t-attf-name="ticket-#{ ticket.id }" class="form-control">
<t t-foreach="range(0, min((ticket.seats_available or 9) + 1, 10))" t-as="nb"><option t-esc="nb"/></t>
</select>
<span t-if="not ticket.seats_available">Sold Out</span>
<span t-if="not ticket.seats_available and ticket.seats_max">Sold Out</span>
</td>
</tr>
</t>
</tbody>
</table>
<button type="submit" class="btn btn-primary btn-lg pull-right" t-if="event.seats_available">Order Now</button>
<button type="submit" class="btn btn-primary btn-lg pull-right" t-if="event.seats_available or not event.seats_max">Order Now</button>
<div class="clearfix"/>
<hr/>
</form>