[FIX] event: make ticket sale start date inclusive

This commit fixes the ticket sale start date to be considered inclusive.

Indeed, before this commit, if the sales of a ticket starts on the 1st of
December, people arriving on the website at that exact date will NOT be able to
buy tickets although they should be. They will have to wait for the next day to
be able to buy tickets.

A small test was added to ensure this behavior.

Task 2415917

closes odoo/odoo#63685

X-original-commit: ea6952fd7ec881b79a7294c40427ce9966997e66
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Aurélien Warnon
2020-12-22 12:01:05 +00:00
parent 5e6fd455b1
commit 9622ffe442
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -145,6 +145,6 @@ class EventTicket(models.Model):
if self.start_sale_date:
ticket = self._set_tz_context()
current_date = fields.Date.context_today(ticket)
return ticket.start_sale_date < current_date
return ticket.start_sale_date <= current_date
else:
return True
@@ -348,6 +348,14 @@ class TestEventTicketData(TestEventCommon):
})
self.assertFalse(second_ticket.sale_available)
self.assertFalse(second_ticket.is_expired)
# sale started today
second_ticket.write({
'start_sale_date': date(2020, 1, 31),
'end_sale_date': date(2020, 2, 20),
})
self.assertTrue(second_ticket.sale_available)
self.assertTrue(second_ticket.is_launched())
self.assertFalse(second_ticket.is_expired)
# incoherent dates are invalid
with self.assertRaises(exceptions.UserError):
second_ticket.write({'end_sale_date': date(2020, 1, 20)})