mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Autocheckin with alert messages
This commit is contained in:
@@ -367,23 +367,6 @@ class HotelFolio(models.Model):
|
||||
'domain': [('id', 'in', return_move_ids)],
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def action_folios_amount(self):
|
||||
reservations = self.env['hotel.reservation'].search([
|
||||
('checkout', '<=', fields.Date.today())
|
||||
])
|
||||
folio_ids = reservations.mapped('folio_id.id')
|
||||
folios = self.env['hotel.folio'].search([('id', 'in', folio_ids)])
|
||||
folios = folios.filtered(lambda r: r.pending_amount > 0)
|
||||
return {
|
||||
'name': _('Pending'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'hotel.folio',
|
||||
'type': 'ir.actions.act_window',
|
||||
'domain': [('id', 'in', folios.ids)]
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def go_to_currency_exchange(self):
|
||||
'''
|
||||
|
||||
@@ -531,6 +531,22 @@ class HotelReservation(models.Model):
|
||||
})
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def autocheckout(self):
|
||||
reservations = self.env['hotel.reservation'].search([
|
||||
('state', 'not in', ('done', 'cancelled')),
|
||||
('checkout', '<', fields.Date.today())
|
||||
])
|
||||
for res in reservations:
|
||||
res.action_reservation_checkout()
|
||||
res_without_checkin = reservations.filtered(
|
||||
lambda r: r.state != 'booking')
|
||||
for res in res_without_checkin:
|
||||
msg = _("No checkin was made for this reservation")
|
||||
res.message_post(subject=_('No Checkins!'),
|
||||
subtype='mt_comment', body=msg)
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def notify_update(self, vals):
|
||||
if 'checkin' in vals or \
|
||||
@@ -1095,7 +1111,9 @@ class HotelReservation(models.Model):
|
||||
def action_reservation_checkout(self):
|
||||
for record in self:
|
||||
record.state = 'done'
|
||||
record.checkin_partner_ids.action_done()
|
||||
if record.checkin_partner_ids:
|
||||
record.checkin_partner_ids.action_done()
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def action_checks(self):
|
||||
|
||||
Reference in New Issue
Block a user