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,19 +1,12 @@
|
||||
<?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"
|
||||
name="Checkins"
|
||||
@@ -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>
|
||||
|
||||
@@ -256,9 +256,8 @@ var HotelCalendarView = AbstractRenderer.extend({
|
||||
model = 'hotel.reservation';
|
||||
title = _t('Reservations');
|
||||
} else if (type === 'checkin') {
|
||||
model = 'hotel.reservation';
|
||||
model = 'hotel.checkin.partner';
|
||||
title = _t('Checkins');
|
||||
domain.splice(0, 0, ['checkin', '=', moment().format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT)]);
|
||||
} else if (type === 'invoice') {
|
||||
model = 'sale.order';
|
||||
title = _t('Invoices');
|
||||
|
||||
@@ -24,3 +24,4 @@ from . import category_type
|
||||
from . import code_ine
|
||||
from . import inherit_res_company
|
||||
from . import inherit_res_partner
|
||||
from . import inherit_hotel_checkin_partner
|
||||
|
||||
38
hotel_l10n_es/models/inherit_hotel_checkin_partner.py
Normal file
38
hotel_l10n_es/models/inherit_hotel_checkin_partner.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Alda Hotels <informatica@aldahotels.com>
|
||||
# Jose Luis Algara <osotranquilo@gmail.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp import models, fields, api, _
|
||||
from odoo.osv.expression import get_unaccent_wrapper
|
||||
|
||||
|
||||
class HotelCheckinPartner(models.Model):
|
||||
_inherit = 'hotel.checkin.partner'
|
||||
|
||||
document_type = fields.Selection(related='partner_id.document_type')
|
||||
document_number = fields.Char(related='partner_id.document_number')
|
||||
document_expedition_date = fields.Date(related='partner_id.document_expedition_date')
|
||||
|
||||
code_ine_id = fields.Many2one(related="partner_id.code_ine_id")
|
||||
|
||||
#TMP_FIX VAT Validation
|
||||
@api.constrains("vat")
|
||||
def check_vat(self):
|
||||
return
|
||||
@@ -68,12 +68,12 @@ class ResPartner(models.Model):
|
||||
|
||||
query = """SELECT id
|
||||
FROM res_partner
|
||||
{where} ({poldocument} {operator} {percent})
|
||||
{where} ({document_number} {operator} {percent})
|
||||
ORDER BY {display_name} {operator} {percent} desc,
|
||||
{display_name}
|
||||
""".format(where=where_str,
|
||||
operator=operator,
|
||||
poldocument=unaccent('poldocument'),
|
||||
document_number=unaccent('document_number'),
|
||||
display_name=unaccent('display_name'),
|
||||
percent=unaccent('%s'),)
|
||||
|
||||
@@ -94,7 +94,7 @@ class ResPartner(models.Model):
|
||||
|
||||
#TODO: Review better VAT & DocumentNumber integration
|
||||
@api.onchange('document_number')
|
||||
def onchange_poldocument(self):
|
||||
def onchange_document_number(self):
|
||||
for partner in self:
|
||||
if partner.document_number and partner.document_type == 'D':
|
||||
partner.vat = 'ES' + partner.poldocument
|
||||
partner.vat = 'ES' + partner.document_number
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='reservation_id']" position="after">
|
||||
<button type="action" class="oe_stat_button"
|
||||
id="cardex_smart_button_2"
|
||||
icon="fa-file-pdf-o"
|
||||
name="%(action_report_viajero)d"
|
||||
context="{'partner_id': partner_id,'enter_date': enter_date,
|
||||
@@ -18,4 +17,48 @@
|
||||
</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="inherit_id" ref="hotel.hotel_checkin_partner_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_on_board']" position="before">
|
||||
<button type="action" class="oe_stat_button"
|
||||
icon="fa fa-2x fa-file-pdf-o"
|
||||
name="%(action_report_viajero)d"
|
||||
context="{'partner_id': partner_id,'enter_date': enter_date,
|
||||
'exit_date': exit_date,'reservation_ids': reservation_id,
|
||||
'hidden_cardex': True, 'edit_cardex': True }"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="document_type"/>
|
||||
<field name="document_number"/>
|
||||
<field name="document_expedition_date"/>
|
||||
<field name="code_ine_id" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hotel_checkin_partner_reservation_view_tree" model="ir.ui.view">
|
||||
<field name="name">hotel.checkin.partner.view.tree</field>
|
||||
<field name="model">hotel.checkin.partner</field>
|
||||
<field name="inherit_id" ref="hotel.hotel_checkin_partner_reservation_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_on_board']" position="before">
|
||||
<button type="action" class="oe_stat_button"
|
||||
icon="fa fa-2x fa-file-pdf-o"
|
||||
name="%(action_report_viajero)d"
|
||||
context="{'partner_id': partner_id,'enter_date': enter_date,
|
||||
'exit_date': exit_date,'reservation_ids': reservation_id,
|
||||
'hidden_cardex': True, 'edit_cardex': True }"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="document_type"/>
|
||||
<field name="document_number"/>
|
||||
<field name="document_expedition_date"/>
|
||||
<field name="code_ine_id" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user