[ADD] Autocheckin with alert messages

This commit is contained in:
Dario Lodeiros
2019-03-19 22:54:49 +01:00
parent 28f1a74061
commit 9fe8af6b31
4 changed files with 614 additions and 556 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<data noupdate="0">
<!-- Scheduler For To Inform Guest About Reservation Before 24 Hours -->
<record model="ir.cron" id="Guest_reservation_reminder_24hrs">
@@ -14,6 +14,21 @@
<field name="code">model.reservation_reminder_24hrs()</field>
</record>
<!-- Scheduler For To Inform Guest About Reservation Before 24 Hours -->
<record model="ir.cron" id="autocheckout_reservations">
<field name="name">Automatic Checkout on past reservations</field>
<field name="interval_number">1</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="state">code</field>
<field name="model_id" ref="model_hotel_reservation" />
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 05:00:00')"/>
<field name="code">model.autocheckout()</field>
</record>
</data>
</odoo>

File diff suppressed because it is too large Load Diff

View File

@@ -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):
'''

View File

@@ -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):