[FIX] website_event_sale: hide event tickets that are not for sale anymore
This should ideally be based on an extra timezone field on each event, pending fix later in trunk. bzr revid: odo@openerp.com-20140422123153-m6za55oqkiqysalx
This commit is contained in:
parent
93cca5eb1d
commit
60cafe4da2
|
@ -167,12 +167,23 @@ class event_ticket(osv.osv):
|
|||
if ticket.seats_max > 0 else None
|
||||
return res
|
||||
|
||||
def _is_expired(self, cr, uid, ids, field_name, args, context=None):
|
||||
# FIXME: A ticket is considered expired when the deadline is passed. The deadline should
|
||||
# be considered in the timezone of the event, not the timezone of the user!
|
||||
# Until we add a TZ on the event we'll use the context's current date, more accurate
|
||||
# than using UTC all the time.
|
||||
current_date = fields.date.context_today(self, cr, uid, context=context)
|
||||
return {ticket.id: ticket.deadline and ticket.deadline < current_date
|
||||
for ticket in self.browse(cr, uid, ids, context=context)}
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
'event_id': fields.many2one('event.event', "Event", required=True, ondelete='cascade'),
|
||||
'product_id': fields.many2one('product.product', 'Product', required=True, domain=[("event_type_id", "!=", False)]),
|
||||
'registration_ids': fields.one2many('event.registration', 'event_ticket_id', 'Registrations'),
|
||||
'deadline': fields.date("Sales End"),
|
||||
'is_expired': fields.function(_is_expired, type='boolean', string='Is Expired'),
|
||||
'price': fields.float('Price'),
|
||||
'seats_max': fields.integer('Maximum Avalaible Seats', oldname='register_max', help="You can for each event define a maximum registration level. If you have too much registrations you are not able to confirm your event. (put 0 to ignore this rule )"),
|
||||
'seats_reserved': fields.function(_get_seats, string='Reserved Seats', type='integer', multi='seats_reserved'),
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="event.event_ticket_ids" t-as="ticket">
|
||||
<t t-foreach="event.event_ticket_ids" t-as="ticket">
|
||||
<tr t-if="not ticket.is_expired">
|
||||
<td>
|
||||
<div t-field="ticket.name"/>
|
||||
<div><small t-field="ticket.product_id.description_sale"/></div>
|
||||
|
@ -67,7 +68,8 @@
|
|||
</select>
|
||||
<span t-if="not ticket.seats_available">Sold Out</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="submit" class="btn btn-primary btn-lg pull-right" t-if="event.seats_available">Order Now</button>
|
||||
|
|
Loading…
Reference in New Issue