add wizard to create party and refix the check_in and check_out
This commit is contained in:
parent
2d3812d553
commit
ed8185e413
|
@ -46,6 +46,7 @@ def register():
|
|||
channel.ChannelTax,
|
||||
booking.Guest,
|
||||
booking.SelectRoomsAsk,
|
||||
party.CreateGuestStart,
|
||||
booking.BookingVoucher,
|
||||
booking.RoomsOccupancyStart,
|
||||
booking.BookingForecastStart,
|
||||
|
@ -99,5 +100,6 @@ def register():
|
|||
housekeeping.HousekeepingService,
|
||||
booking.GuestsList,
|
||||
sale.InvoiceIncomeDaily,
|
||||
party.CreateGuest,
|
||||
# voucher.AdvanceVoucher,
|
||||
module='hotel', type_='wizard')
|
||||
|
|
202
booking.py
202
booking.py
|
@ -246,6 +246,9 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
cls._buttons.update({
|
||||
'select_rooms': {
|
||||
'invisible': Eval('state') != 'offer',
|
||||
},
|
||||
'create_guest': {
|
||||
|
||||
},
|
||||
'cancel': {
|
||||
'invisible': Eval('state').in_(['cancel', '']) and
|
||||
|
@ -280,7 +283,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
},
|
||||
'send_email': {
|
||||
'invisible': Eval('state') != 'confirmed'
|
||||
},
|
||||
},
|
||||
})
|
||||
cls._error_messages.update({
|
||||
'invalid_number_principal_guest': ('Must exist one principal guest'),
|
||||
|
@ -300,20 +303,16 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
def trigger_create(cls, records):
|
||||
cls.set_number(records)
|
||||
|
||||
# @classmethod
|
||||
# def copy(cls, bookings, default=None):
|
||||
# if default is None:
|
||||
# default = {}
|
||||
# default = default.copy()
|
||||
# default['number'] = None
|
||||
# default['registration_card'] = None
|
||||
# default['state'] = 'offer'
|
||||
# default['booking_date'] = datetime.now()
|
||||
# new_bookings = []
|
||||
# for booking in bookings:
|
||||
# new_bookings, = super(Booking, cls).copy([booking], default=default)
|
||||
# new_bookings.append(new_bookings)
|
||||
# return new_bookings
|
||||
@classmethod
|
||||
def copy(cls, bookings, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default['number'] = None
|
||||
default['registration_card'] = None
|
||||
default['state'] = 'offer'
|
||||
default['booking_date'] = datetime.now()
|
||||
return super(Booking, cls).copy(bookings, default=default)
|
||||
|
||||
@staticmethod
|
||||
def default_currency():
|
||||
|
@ -383,6 +382,11 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
def select_rooms(cls, bookings):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('hotel.wizard_party_guest')
|
||||
def create_guest(cls, bookings):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('hotel.wizard_booking_advance_voucher')
|
||||
def pay_advance(cls, bookings):
|
||||
|
@ -418,44 +422,55 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
# FIXME check if does not exist previous occupancy if exist update state
|
||||
rec.create_occupancy()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def check_in(cls, records):
|
||||
config_party = Pool().get('party.configuration')(1)
|
||||
validate_party = config_party.validate_party
|
||||
if not validate_party:
|
||||
config_party.validate_party = True
|
||||
config_party.save()
|
||||
for record in records:
|
||||
record.party.pre_validate()
|
||||
cls.set_registration_card_number([record])
|
||||
for line in record.lines:
|
||||
if line.main_guest is None:
|
||||
cls.raise_user_error('missing_main_guest')
|
||||
if line.room is None:
|
||||
cls.raise_user_error('missing_select_room')
|
||||
record.check_rooms()
|
||||
cls.write([record], {'registration_state': 'check_in'})
|
||||
record.update_occupancy(state='open')
|
||||
if config_party.validate_party != validate_party:
|
||||
config_party.validate_party = validate_party
|
||||
config_party.save()
|
||||
# @classmethod
|
||||
# @ModelView.button
|
||||
# def check_in(cls, records):
|
||||
# CHECK_INDIVIDUAL = False
|
||||
# Line = Pool().get('hotel.booking.line')
|
||||
# check_in_(records,CHECK_INDIVIDUAL)
|
||||
# for record in records:
|
||||
# for line in record.lines:
|
||||
# Line.write([line], {'registration_state_': 'check_in'})
|
||||
# # config_party = Pool().get('party.configuration')(1)
|
||||
# # validate_party = config_party.validate_party
|
||||
# # if not validate_party:
|
||||
# # config_party.validate_party = True
|
||||
# # config_party.save()
|
||||
# # for record in records:
|
||||
# # record.party.pre_validate()
|
||||
# # cls.set_registration_card_number([record])
|
||||
# # for line in record.lines:
|
||||
# # if line.main_guest is None:
|
||||
# # cls.raise_user_error('missing_main_guest')
|
||||
# # if line.room is None:
|
||||
# # cls.raise_user_error('missing_select_room')
|
||||
# # record.check_rooms()
|
||||
# # cls.write([record], {'registration_state': 'check_in'})
|
||||
# # record.update_occupancy(state='open')
|
||||
# # if config_party.validate_party != validate_party:
|
||||
# # config_party.validate_party = validate_party
|
||||
# # config_party.save()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def no_show(cls, records):
|
||||
check = False
|
||||
for record in records:
|
||||
record.update_occupancy(state='cancelled')
|
||||
record.update_occupancy(state='cancelled',records=records,check=check)
|
||||
cls.write([record], {'registration_state': 'no_show'})
|
||||
record.cancel_occupancy()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def check_out(cls, records):
|
||||
for record in records:
|
||||
cls.write([record], {'registration_state': 'check_out'})
|
||||
record.update_occupancy(state='closed')
|
||||
pass
|
||||
# @classmethod
|
||||
# @ModelView.button
|
||||
# def check_out(cls, records):
|
||||
# CHECK_INDIVIDUAL = False
|
||||
# Line = Pool().get('hotel.booking.line')
|
||||
# for record in records:
|
||||
# cls.write([record], {'registration_state': 'check_out'})
|
||||
# update_occupancy(state='closed',check=CHECK_INDIVIDUAL,records=records)
|
||||
# for line in record.lines:
|
||||
# Line.write([line], {'registration_state_': 'check_out'})
|
||||
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
@ -577,11 +592,12 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
context['taxes'] = taxes
|
||||
return context
|
||||
|
||||
def update_occupancy(self, state):
|
||||
def update_occupancy(self, state, records, check):
|
||||
Operation = Pool().get('hotel.operation')
|
||||
OperationVoucher = Pool().get('hotel.operation-account.voucher')
|
||||
vouchers_added = False
|
||||
for line in self.lines:
|
||||
lines = records if check == True else self.lines
|
||||
for line in lines:
|
||||
# if state != 'open':
|
||||
# continue
|
||||
guests = [{
|
||||
|
@ -599,11 +615,11 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
Operation.write([line.operation], {
|
||||
'state': state,
|
||||
'main_guest': line.main_guest.id,
|
||||
'party': self.party.id,
|
||||
'party': line.booking.party.id,
|
||||
'unit_price': line.unit_price,
|
||||
'start_date': line.arrival_date,
|
||||
'end_date': line.departure_date,
|
||||
'reference': self.registration_card,
|
||||
'reference': line.booking.registration_card,
|
||||
'guests': [('create', guests)]
|
||||
})
|
||||
|
||||
|
@ -681,6 +697,9 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
else:
|
||||
self.get_message('El usuario no tiene un correo asociado.')
|
||||
|
||||
def get_message(self, message):
|
||||
self.raise_user_error(message)
|
||||
|
||||
|
||||
class BookingLine(ModelSQL, ModelView):
|
||||
'Booking Line'
|
||||
|
@ -727,6 +746,8 @@ class BookingLine(ModelSQL, ModelView):
|
|||
select=True)
|
||||
target_city = fields.Many2One('hotel.migration_city', 'Target City',
|
||||
select=True)
|
||||
registration_state = fields.Selection(REGISTRATION_STATE, 'State Registration',
|
||||
readonly=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -740,11 +761,15 @@ class BookingLine(ModelSQL, ModelView):
|
|||
'occupied_room': ('The room is occupied in the date %s'),
|
||||
'restring_room': ('The room %s is in restring access for quarantine protocolo!'),
|
||||
})
|
||||
# cls._buttons.update({
|
||||
# 'create_guest': {
|
||||
#
|
||||
# }
|
||||
# )
|
||||
cls._buttons.update({
|
||||
'check_in': {
|
||||
'invisible': Eval('booking.state') != 'confirmed' and
|
||||
Eval('registration_state').in_(['check_in', 'check_out']),
|
||||
},
|
||||
'check_out': {
|
||||
'invisible': Eval('booking.state') != 'confirmed' and
|
||||
Eval('registration_state') == 'check_out',
|
||||
}})
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
|
@ -772,11 +797,46 @@ class BookingLine(ModelSQL, ModelView):
|
|||
values.update({'start_date': vals['arrival_date']})
|
||||
if vals.get('departure_date'):
|
||||
values.update({'end_date': vals['departure_date']})
|
||||
|
||||
if values:
|
||||
Operation.write([line.operation], values)
|
||||
super(BookingLine, cls).write(*args)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def check_in(cls, records):
|
||||
check = True
|
||||
pool = Pool()
|
||||
Booking = pool.get('hotel.booking')
|
||||
config_party = Pool().get('party.configuration')(1)
|
||||
validate_party = config_party.validate_party
|
||||
if not validate_party:
|
||||
config_party.validate_party = True
|
||||
config_party.save()
|
||||
config_party.save()
|
||||
record = records[0].booking
|
||||
record.party.pre_validate()
|
||||
Booking.set_registration_card_number([record])
|
||||
line = records[0]
|
||||
if line.main_guest is None:
|
||||
Booking.raise_user_error('missing_main_guest')
|
||||
if line.room is None:
|
||||
Booking.raise_user_error('missing_select_room')
|
||||
record.check_rooms()
|
||||
cls.write([records[0]], {'registration_state': 'check_in'})
|
||||
record.update_occupancy(state='open',records=records,check=check)
|
||||
if config_party.validate_party != validate_party:
|
||||
config_party.validate_party = validate_party
|
||||
config_party.save()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def check_out(cls, records):
|
||||
check = True
|
||||
for record in records:
|
||||
cls.write([record], {'registration_state': 'check_out'})
|
||||
record.booking.update_occupancy(state='closed',records=records,check=check)
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def default_main_guest():
|
||||
party = Transaction().context.get('party')
|
||||
|
@ -802,7 +862,7 @@ class BookingLine(ModelSQL, ModelView):
|
|||
def validate(cls, lines):
|
||||
super(BookingLine, cls).validate(lines)
|
||||
for line in lines:
|
||||
# line.check_method()
|
||||
line.check_method()
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
|
@ -871,21 +931,21 @@ class BookingLine(ModelSQL, ModelView):
|
|||
if self.arrival_date >= self.departure_date:
|
||||
self.raise_user_error('invalid_date')
|
||||
Operation = Pool().get('hotel.operation')
|
||||
# operations = Operation.search([
|
||||
# ('room', '=', self.room.id),
|
||||
# ['AND',
|
||||
# ['OR', [
|
||||
# ('start_date', '>=', self.arrival_date),
|
||||
# ('end_date', '<=', self.arrival_date),
|
||||
# ], [
|
||||
# ('start_date', '>=', self.departure_date),
|
||||
# ('end_date', '<=', self.departure_date),
|
||||
# ],
|
||||
# ]]
|
||||
# ])
|
||||
# print(operations)
|
||||
# if operations:
|
||||
# self.raise_user_error('occupied_room', self.departure_date)
|
||||
operations = Operation.search([
|
||||
('room', '=', self.room.id),
|
||||
['AND',
|
||||
['OR', [
|
||||
('start_date', '>=', self.arrival_date),
|
||||
('end_date', '<=', self.arrival_date),
|
||||
], [
|
||||
('start_date', '>=', self.departure_date),
|
||||
('end_date', '<=', self.departure_date),
|
||||
],
|
||||
]]
|
||||
])
|
||||
print(operations)
|
||||
if operations:
|
||||
self.raise_user_error('occupied_room', self.departure_date)
|
||||
config = Pool().get('hotel.configuration')(1)
|
||||
quarantine_days = config.quarantine_rooms
|
||||
room_id = self.room.id
|
||||
|
|
|
@ -83,13 +83,13 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_booking_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_booking_form_domain_check_in">
|
||||
<!-- <record model="ir.action.act_window.domain" id="act_booking_form_domain_check_in">
|
||||
<field name="name">Check In</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain" eval="[('registration_state', '=', 'check_in')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_booking_form"/>
|
||||
</record>
|
||||
</record> -->
|
||||
<record model="ir.action.act_window.domain" id="act_booking_form_domain_no_show">
|
||||
<field name="name">No Show</field>
|
||||
<field name="sequence" eval="50"/>
|
||||
|
|
68
party.py
68
party.py
|
@ -1,10 +1,13 @@
|
|||
#This file is part of Hotel module for Tryton. The COPYRIGHT file at
|
||||
#the top level of this repository contains the full copyright notices
|
||||
#and license terms.
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields, ModelView
|
||||
from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['Party']
|
||||
|
||||
__all__ = ['Party','CreateGuest','CreateGuestStart']
|
||||
|
||||
|
||||
TYPE = [
|
||||
|
@ -14,6 +17,19 @@ TYPE = [
|
|||
('implicit', 'Implicit'),
|
||||
]
|
||||
|
||||
TYPE_DOCUMENT = [
|
||||
('', ''),
|
||||
('11', 'Civil Registry of Birth'),
|
||||
('12', 'Identity Card'),
|
||||
('13', 'Citizenship Card'),
|
||||
('21', 'Tarjeta de Extranjeria'),
|
||||
('22', 'Alien Registration Card'),
|
||||
('31', 'NIT'),
|
||||
('41', 'Passport'),
|
||||
('42', 'Type of Foreign Document'),
|
||||
('43', 'Without Foreign Identification or for use as defined by the DIAN'),
|
||||
]
|
||||
|
||||
|
||||
class Party(metaclass=PoolMeta):
|
||||
__name__ = 'party.party'
|
||||
|
@ -33,3 +49,49 @@ class Party(metaclass=PoolMeta):
|
|||
visa_category = fields.Char('Visa Category')
|
||||
visa_number = fields.Char('Visa Number')
|
||||
visa_date = fields.Date('Visa Date')
|
||||
|
||||
class CreateGuestStart(ModelView):
|
||||
'Create Party to Guest Start'
|
||||
__name__ = 'hotel.party.guest.start'
|
||||
name = fields.Char('Name', required=True)
|
||||
type_document = fields.Selection(TYPE_DOCUMENT, 'Type Document')
|
||||
id_number = fields.Char('Id Number')
|
||||
|
||||
class CreateGuest(Wizard):
|
||||
'Create Party to Guest'
|
||||
__name__ = 'hotel.party.guest'
|
||||
start = StateView('hotel.party.guest.start',
|
||||
'hotel.view_party_guest', [
|
||||
Button('Exit', 'end', 'tryton-cancel'),
|
||||
Button('Create', 'create_', 'tryton-ok', default=True),
|
||||
]
|
||||
)
|
||||
create_ = StateTransition()
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(CreateGuest, cls).__setup__()
|
||||
|
||||
def transition_create_(self):
|
||||
pool = Pool()
|
||||
Party = pool.get('party.party')
|
||||
Booking = pool.get('hotel.booking')
|
||||
id = Transaction().context.get('active_id', False)
|
||||
record = Booking(id)
|
||||
parties = Party.search([
|
||||
('id_number', '=', self.start.id_number)
|
||||
])
|
||||
if parties:
|
||||
self.get_message(('El usuario %s ya existe')%(self.start.name))
|
||||
else:
|
||||
party, = Party.create([{
|
||||
'name': self.start.name,
|
||||
'type_document': self.start.type_document,
|
||||
'id_number': self.start.id_number
|
||||
}])
|
||||
party.save()
|
||||
Booking.write([record], {'party': party})
|
||||
return 'end'
|
||||
|
||||
def get_message(self, message):
|
||||
self.raise_user_error(message)
|
||||
|
|
11
party.xml
11
party.xml
|
@ -3,7 +3,16 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_party_guest">
|
||||
<field name="name">Create Party Guest</field>
|
||||
<field name="wiz_name">hotel.party.guest</field>
|
||||
<field name="model">hotel.party</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_party_guest">
|
||||
<field name="model">hotel.party.guest.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">party_guest</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="party_view_form">
|
||||
<field name="model">party.party</field>
|
||||
<field name="inherit" ref="party.party_view_form"/>
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<form col="6">
|
||||
<label name="party"/>
|
||||
<field name="party" colspan="3"/>
|
||||
<field name="party"/>
|
||||
<button name="create_guest" string="Create Guest"
|
||||
icon="tryton-open" colspan="2"/>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
<label name="contact"/>
|
||||
|
@ -92,7 +94,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<label name="total_advance"/>
|
||||
<field name="total_advance"/>
|
||||
</group>
|
||||
<group col="2" colspan="2" id="amounts">
|
||||
<group col="6" colspan="3" id="amounts">
|
||||
<label name="untaxed_amount"/>
|
||||
<field name="untaxed_amount"/>
|
||||
<label name="tax_amount"/>
|
||||
|
@ -103,10 +105,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<group col="8" colspan="5" id="registration_buttons">
|
||||
<label name="registration_state"/>
|
||||
<field name="registration_state"/>
|
||||
<button name="check_in" string="Check In"
|
||||
<!-- <button name="check_in" string="Check In"
|
||||
icon="tryton-forward"/>
|
||||
<button name="check_out" string="Check Out"
|
||||
icon="tryton-ok"/>
|
||||
icon="tryton-ok"/> -->
|
||||
<button name="no_show" string="No Show"
|
||||
icon="tryton-cancel"/>
|
||||
</group>
|
||||
|
|
|
@ -33,6 +33,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="guests" colspan="4"/>
|
||||
<separator name="notes" colspan="4"/>
|
||||
<field name="notes" colspan="4"/>
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<!-- <label name="state"/>
|
||||
<field name="state"/> -->
|
||||
<label name="registration_state"/>
|
||||
<field name="registration_state"/>
|
||||
</form>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="product"/>
|
||||
<button name="check_in" string="Check In" type="object"/>
|
||||
<button name="check_out" string="Check Out"/>
|
||||
<field name="main_guest"/>
|
||||
<field name="room"/>
|
||||
<field name="nights_quantity"/>
|
||||
|
@ -11,5 +13,5 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="unit_price"/>
|
||||
<field name="total_amount"/>
|
||||
<field name="host_quantity"/>
|
||||
<field name="state"/>
|
||||
<field name="registration_state"/>
|
||||
</tree>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="type_document"/>
|
||||
<field name="type_document"/>
|
||||
<label name="id_number"/>
|
||||
<field name="id_number"/>
|
||||
</form>
|
Loading…
Reference in New Issue