[WIP] datetime by date

This commit is contained in:
Pablo Quesada Barriuso
2018-07-30 16:47:10 +02:00
parent 0071cb9991
commit ebc8891f76

View File

@@ -225,15 +225,6 @@ class HotelReservation(models.Model):
else: else:
return default_departure_hour return default_departure_hour
# @api.constrains('checkin', 'checkout') #Why dont run api.depends?¿?
# def _computed_nights(self):
# for res in self:
# if res.checkin and res.checkout:
# nights = days_diff = date_utils.date_diff(
# self.checkin,
# self.checkout, hours=False)
# res.nights = nights
@api.model @api.model
def name_search(self, name='', args=None, operator='ilike', limit=100): def name_search(self, name='', args=None, operator='ilike', limit=100):
if args is None: if args is None:
@@ -628,17 +619,12 @@ class HotelReservation(models.Model):
@api.model @api.model
def checkin_is_today(self): def checkin_is_today(self):
self.ensure_one() self.ensure_one()
date_now_str = date_utils.now().strftime( return (self.checkin == fields.Date.context_today(self))
DEFAULT_SERVER_DATE_FORMAT)
return date_utils.date_compare(self.checkin, date_now_str, hours=False)
@api.model @api.model
def checkout_is_today(self): def checkout_is_today(self):
self.ensure_one() self.ensure_one()
date_now_str = date_utils.now().strftime( return (self.checkout == fields.Date.context_today(self))
DEFAULT_SERVER_DATE_FORMAT)
return date_utils.date_compare(self.checkout, date_now_str,
hours=False)
@api.multi @api.multi
def action_cancel(self): def action_cancel(self):
@@ -1308,8 +1294,12 @@ class HotelReservation(models.Model):
@param dto: range date to @param dto: range date to
@return: array with the reservations _confirmed_ between dfrom and dto @return: array with the reservations _confirmed_ between dfrom and dto
""" """
# QUESTION dto must be strictly <
domain = [('reservation_line_ids.date', '>=', dfrom), domain = [('reservation_line_ids.date', '>=', dfrom),
('reservation_line_ids.date', '<=', dto), ('reservation_line_ids.date', '<', dto),
('state', '!=', 'cancelled'), ('state', '!=', 'cancelled'),
('overbooking', '=', False)] ('overbooking', '=', False)]
reservations = self.env['hotel.reservation'].search(domain)
_logger.info('get_reservations: Found')
_logger.info(reservations)
return self.env['hotel.reservation'].search(domain) return self.env['hotel.reservation'].search(domain)