mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Checkin Workflow
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
'depends': [
|
||||
'sale_stock',
|
||||
'account_payment_return',
|
||||
'partner_firstname',
|
||||
],
|
||||
'license': "AGPL-3",
|
||||
'demo': ['data/hotel_demo.xml'],
|
||||
|
||||
@@ -17,6 +17,14 @@ class HotelCheckinPartner(models.Model):
|
||||
return reservation
|
||||
return False
|
||||
|
||||
def _default_folio_id(self):
|
||||
if 'folio_id' in self.env.context:
|
||||
folio = self.env['hotel.folio'].browse([
|
||||
self.env.context['reservation_id']
|
||||
])
|
||||
return folio
|
||||
raise ValidationError(_('You only can create checkin from reservations or folios'))
|
||||
|
||||
def _default_enter_date(self):
|
||||
if 'reservation_id' in self.env.context:
|
||||
reservation = self.env['hotel.reservation'].browse([
|
||||
@@ -45,10 +53,18 @@ class HotelCheckinPartner(models.Model):
|
||||
partner_id = fields.Many2one('res.partner', default=_default_partner_id,
|
||||
required=True)
|
||||
reservation_id = fields.Many2one(
|
||||
'hotel.reservation',
|
||||
default=_default_reservation_id, readonly=True)
|
||||
'hotel.reservation', default=_default_reservation_id)
|
||||
folio_id = fields.Many2one('hotel.reservation',
|
||||
default=_default_folio_id, readonly=True)
|
||||
enter_date = fields.Date(default=_default_enter_date, required=True)
|
||||
exit_date = fields.Date(default=_default_exit_date, required=True)
|
||||
state = fields.Selection([('draft', 'Pending Entry'),
|
||||
('booking', 'On Board'),
|
||||
('done', 'Out'),
|
||||
('cancelled', 'Cancelled')],
|
||||
'State', readonly=True,
|
||||
default=lambda *a: 'draft',
|
||||
track_visibility='onchange')
|
||||
|
||||
# Validation for Departure date is after arrival date.
|
||||
@api.multi
|
||||
@@ -72,3 +88,13 @@ class HotelCheckinPartner(models.Model):
|
||||
raise ValidationError(
|
||||
_('Departure date, is prior to arrival. Check it now. %s') %
|
||||
date_out)
|
||||
|
||||
@api.multi
|
||||
def action_on_board(self):
|
||||
for record in self:
|
||||
record.state = 'booking'
|
||||
|
||||
@api.multi
|
||||
def action_done(self):
|
||||
for record in self:
|
||||
record.state = 'done'
|
||||
|
||||
@@ -188,6 +188,7 @@ class HotelFolio(models.Model):
|
||||
compute='_amount_all', track_visibility='always')
|
||||
|
||||
#Checkin Fields-----------------------------------------------------
|
||||
checkin_partner_ids = fields.One2many('hotel.checkin.partner', 'reservation_id')
|
||||
booking_pending = fields.Integer('Booking pending',
|
||||
compute='_compute_checkin_partner_count')
|
||||
checkin_partner_count = fields.Integer('Checkin counter',
|
||||
@@ -567,7 +568,6 @@ class HotelFolio(models.Model):
|
||||
|
||||
@api.multi
|
||||
def _compute_checkin_partner_count(self):
|
||||
_logger.info('_compute_checkin_partner_amount')
|
||||
for record in self:
|
||||
if record.reservation_type == 'normal' and record.room_lines:
|
||||
write_vals = {}
|
||||
|
||||
@@ -572,6 +572,13 @@ class HotelReservation(models.Model):
|
||||
if self.reservation_type == 'out':
|
||||
self.update({'partner_id': self.env.user.company_id.partner_id.id})
|
||||
|
||||
@api.multi
|
||||
@api.onchange('checkin_partner_ids')
|
||||
def onchange_checkin_partner_ids(self):
|
||||
for record in self:
|
||||
if len(record.checkin_partner_ids) > record.adults + record.children:
|
||||
raise models.ValidationError(_('The room already is completed'))
|
||||
|
||||
# When we need to overwrite the prices even if they were already established
|
||||
@api.onchange('room_type_id', 'pricelist_id', 'reservation_type')
|
||||
def onchange_overwrite_price_by_day(self):
|
||||
@@ -953,6 +960,13 @@ class HotelReservation(models.Model):
|
||||
CHECKIN/OUT PROCESS ------------------------------------------------
|
||||
"""
|
||||
|
||||
@api.multi
|
||||
@api.constrains('checkin_partner_ids')
|
||||
def _max_checkin_partner_ids(self):
|
||||
for record in self:
|
||||
if len(record.checkin_partner_ids) > record.adults + record.children:
|
||||
raise models.ValidationError(_('The room already is completed'))
|
||||
|
||||
@api.multi
|
||||
def _compute_checkin_partner_count(self):
|
||||
_logger.info('_compute_checkin_partner_count')
|
||||
@@ -972,6 +986,7 @@ class HotelReservation(models.Model):
|
||||
def action_reservation_checkout(self):
|
||||
for record in self:
|
||||
record.state = 'done'
|
||||
record.checkin_partner_ids.action_done()
|
||||
|
||||
@api.multi
|
||||
def action_checks(self):
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Action to open INE Codes list -->
|
||||
<act_window
|
||||
id="action_checkin_partner"
|
||||
name="Action checkin"
|
||||
res_model='hotel.checkin.partner'
|
||||
view_mode="tree,form" />
|
||||
|
||||
<act_window
|
||||
id="action_checkin_partner_download"
|
||||
name="Action checkin download"
|
||||
res_model='hotel.checkin.partner'
|
||||
view_mode="form" />
|
||||
|
||||
<menuitem
|
||||
id="menu_hotel_checkin_partner"
|
||||
@@ -25,7 +18,7 @@
|
||||
<field name="name">Checkin Form</field>
|
||||
<field name="model">hotel.checkin.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form create="false">
|
||||
<sheet>
|
||||
<group name="group_top">
|
||||
<group name="group_left">
|
||||
@@ -42,17 +35,92 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hotel_checkin_partner_view_tree" model="ir.ui.view">
|
||||
<field name="name">Checkin Tree</field>
|
||||
<record id="hotel_checkin_partner_reservation_view_tree" model="ir.ui.view">
|
||||
<field name="name">hotel.checkin.partner.reservation.view.tree</field>
|
||||
<field name="model">hotel.checkin.partner</field>
|
||||
<field name="priority">20</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="partner_id" string="Client name"/>
|
||||
<tree editable="bottom"
|
||||
decoration-danger="state == 'draft'"
|
||||
decoration-muted="state == 'cancelled' or state =='done'"
|
||||
decoration-success="state == 'booking'">
|
||||
<button type="object" class="oe_stat_button"
|
||||
icon="fa fa-2x fa-check-circle"
|
||||
name="action_on_board"
|
||||
attrs="{'invisible':[('state','not in', ['draft'])]}"
|
||||
help="Get in"
|
||||
/>
|
||||
<field name="partner_id" required="True"/>
|
||||
<field name="enter_date"/>
|
||||
<field name="exit_date"/>
|
||||
<field name="reservation_id"/>
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hotel_checkin_partner_view_tree" model="ir.ui.view">
|
||||
<field name="name">hotel.checkin.partner.view.tree</field>
|
||||
<field name="model">hotel.checkin.partner</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree create="false"
|
||||
decoration-danger="state == 'draft'"
|
||||
decoration-muted="state == 'cancelled' or state =='done'"
|
||||
decoration-success="state == 'booking'">
|
||||
<button type="object" class="oe_stat_button"
|
||||
icon="fa fa-2x fa-check-circle"
|
||||
name="action_on_board"
|
||||
attrs="{'invisible':[('state','not in', ['draft'])]}"
|
||||
help="Get in"
|
||||
/>
|
||||
<field name="partner_id" required="True"/>
|
||||
<field name="enter_date"/>
|
||||
<field name="exit_date"/>
|
||||
<field name="reservation_id"/>
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="hotel_checkin_partner_view_search">
|
||||
<field name="name">hotel.checkin.partner.search</field>
|
||||
<field name="model">hotel.checkin.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Checkin Detail">
|
||||
<field name="partner_id" />
|
||||
<field name="reservation_id" />
|
||||
<filter string="On Board"
|
||||
domain="[('state','in',['booking'])]"
|
||||
help="Current Booking" />
|
||||
<filter string="To enter"
|
||||
domain="[('state', '=', 'draft')]"
|
||||
/>
|
||||
<filter string="Out"
|
||||
domain="[('state', '=', 'done')]"
|
||||
/>
|
||||
<filter string="Checkins Tomorrow" name="enter_tomorrow"
|
||||
domain="[('enter_date', '=', (context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d')),
|
||||
('state', '=', 'draft')]"
|
||||
help="Show all checkins for enter tomorrow"/>
|
||||
<filter string="Checkins to 7 days" name="next_res_week"
|
||||
domain="[('enter_date', '<', (context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')),
|
||||
('state', '=', 'draft')]"
|
||||
help="Show all reservations for which date enter is before than 7 days"/>
|
||||
<filter string="On Board Tomorrow" name="next_res_2week"
|
||||
domain="[('enter_date', '<', (context_today()+datetime.timedelta(days=14)).strftime('%Y-%m-%d')),
|
||||
('state', 'in', ['confirm','draft'])]"
|
||||
help="Show all checkins for Tomorrow"/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Creation Date" domain="[]"
|
||||
context="{'group_by':'create_date'}" />
|
||||
<filter string="Checkin Date" domain="[]"
|
||||
context="{'group_by':'checkin'}" />
|
||||
<filter string="Checkout Date" domain="[]"
|
||||
context="{'group_by':'checkout'}" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
<sheet>
|
||||
<div class="oe_button_box" attrs="{'invisible': [('folio_id','=',False)]}">
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="folio_smart_button"
|
||||
icon="fa-file"
|
||||
name="open_folio">
|
||||
<div class="o_form_field o_stat_info">
|
||||
@@ -90,7 +89,6 @@
|
||||
</div>
|
||||
</button>
|
||||
<button type="action" class="oe_stat_button"
|
||||
id="books"
|
||||
icon="fa-list-ul"
|
||||
attrs="{'invisible': [('partner_id','=',False)]}"
|
||||
name="%(open_hotel_reservation_form_tree_all)d"
|
||||
@@ -109,7 +107,6 @@
|
||||
</div>
|
||||
</button>
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="open_master"
|
||||
icon="fa-chain-broken"
|
||||
name="open_master"
|
||||
attrs="{'invisible':[('splitted','=',False)]}">
|
||||
@@ -120,7 +117,6 @@
|
||||
</div>
|
||||
</button>
|
||||
<button type="action" class="oe_stat_button"
|
||||
id="pending_checkins_smart_button"
|
||||
icon="fa-user-plus"
|
||||
name="%(launch_checkin_wizard_add)d"
|
||||
context="{'partner_id': partner_id,'enter_date': checkin,
|
||||
@@ -134,7 +130,6 @@
|
||||
</div>
|
||||
</button>
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="checkin_smart_button"
|
||||
icon="fa-users"
|
||||
name="action_checks"
|
||||
attrs="{'invisible': ['|', ('checkin_partner_count','<=',0),
|
||||
@@ -253,7 +248,7 @@
|
||||
decoration-success="is_board_service == True">
|
||||
<field name="is_board_service" invisible="1" />
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="included_in_room" icon="fa fa-1x fa-bed"
|
||||
icon="fa fa-1x fa-bed"
|
||||
name="open_service_lines"
|
||||
attrs="{'invisible':[('is_board_service','=', False)]}" />
|
||||
<field name="per_day" invisible="1"/>
|
||||
@@ -266,7 +261,7 @@
|
||||
<field name="name"/>
|
||||
<field name="product_qty" attrs="{'readonly': [('per_day','=',True)]}" force_save="1"/>
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="go_service_lines" icon="fa fa-2x fa-bars"
|
||||
icon="fa fa-2x fa-bars"
|
||||
name="open_service_lines"
|
||||
attrs="{'invisible': [('per_day','=',False)]}"/>
|
||||
<field name="days_qty" invisible="1"/>
|
||||
@@ -295,6 +290,15 @@
|
||||
</field>
|
||||
</group>
|
||||
</page>
|
||||
<page name="persons" string="Persons">
|
||||
<field name="checkin_partner_ids"
|
||||
context="{
|
||||
'default_reservation_id': id,
|
||||
'reservation_id': id,
|
||||
'tree_view_ref':'hotel.hotel_checkin_partner_reservation_view_tree',
|
||||
}"
|
||||
/>
|
||||
</page>
|
||||
<page name="others" string="Others">
|
||||
<group>
|
||||
<field name="segmentation_ids" widget="many2many_tags" placeholder="Segmentation..."
|
||||
@@ -337,7 +341,6 @@
|
||||
<button icon="fa fa-2x fa-angellist"
|
||||
attrs="{'invisible':['|',('folio_pending_amount','>',0),('state' ,'!=', 'done')]}"
|
||||
type="object"
|
||||
id="open_folio"
|
||||
name="open_folio" />
|
||||
<field name="state" />
|
||||
<button type="object" class="oe_stat_button"
|
||||
@@ -396,7 +399,6 @@
|
||||
<tree position="attributes">
|
||||
<attribute name="editable">bottom</attribute>
|
||||
<attribute name="delete">false</attribute>
|
||||
<attribute name="options">{'no_open': True}</attribute>
|
||||
<attribute name="string">Rooms</attribute>
|
||||
</tree>
|
||||
<xpath expr="//field[@name='folio_id']" position="attributes">
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
decoration-success="is_board_service == True">
|
||||
<field name="is_board_service" invisible="1" />
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="included_in_room" icon="fa fa-1x fa-bed"
|
||||
icon="fa fa-1x fa-bed"
|
||||
name="open_service_lines"
|
||||
attrs="{'invisible':[('is_board_service','=', False)]}" />
|
||||
<field name="per_day" invisible="1"/>
|
||||
@@ -63,7 +63,7 @@
|
||||
<field name="name"/>
|
||||
<field name="product_qty" attrs="{'readonly': [('per_day','=',True)]}" force_save="1"/>
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="go_service_lines" icon="fa fa-2x fa-bars"
|
||||
icon="fa fa-2x fa-bars"
|
||||
name="open_service_lines"
|
||||
attrs="{'invisible': [('per_day','=',False)]}"/>
|
||||
<field name="days_qty" invisible="1"/>
|
||||
@@ -102,6 +102,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Action for hotel service -->
|
||||
<record model="ir.actions.act_window" id="action_hotel_services_form">
|
||||
<field name="name">Hotel Services</field>
|
||||
|
||||
Reference in New Issue
Block a user