Improvement breakfast, states registration, kind

This commit is contained in:
Oscar 2021-09-13 12:24:22 -05:00
parent d671b5204b
commit c0df7de168
7 changed files with 76 additions and 54 deletions

View File

@ -39,9 +39,9 @@ STATES_CONFIRMED = {
'required': Eval('state') == 'confirmed',
}
STATES_PROCESSING = {
'readonly': Eval('state').in_(['check_in', 'no_show', 'cancelled']),
'required': Eval('state') == 'check_in',
STATES_CHECKIN = {
'readonly': Eval('registration_state').in_(['check_in', 'no_show', 'cancelled']),
'required': Eval('registration_state') == 'check_in',
}
SEGMENT = [
@ -136,9 +136,9 @@ class Booking(Workflow, ModelSQL, ModelView):
'required': Eval('state') == 'check_in',
'readonly': Not(In(Eval('state'), ['offer', 'confirmed'])),
})
contact = fields.Char('Contact', states=STATES_PROCESSING)
contact = fields.Char('Contact', states=STATES_CHECKIN)
payment_term = fields.Many2One('account.invoice.payment_term',
'Payment Term', states=STATES_PROCESSING)
'Payment Term', states=STATES_CHECKIN)
booking_date = fields.DateTime('Booking Date', readonly=False, states=STATES)
person_num = fields.Integer('Person Number', states=STATES)
group = fields.Boolean('Group', states=STATES)
@ -148,7 +148,7 @@ class Booking(Workflow, ModelSQL, ModelView):
'required': Bool(Eval('complementary')),
})
party_seller = fields.Many2One('hotel.channel', 'Channel',
states=STATES_PROCESSING, help="Agency or channel that do reservation.")
states=STATES_CHECKIN, help="Agency or channel that do reservation.")
state = fields.Selection(STATE, 'State', readonly=True, required=True)
registration_state = fields.Selection(REGISTRATION_STATE, 'State Registration',
readonly=True, depends=['lines'])
@ -165,10 +165,10 @@ class Booking(Workflow, ModelSQL, ModelView):
lines = fields.One2Many('hotel.booking.line', 'booking', 'Lines',
states={
'required': Eval('state') == 'confirmed',
'readonly': Not(In(Eval('state'), ['offer', 'confirmed'])),
'readonly': Eval('registration_state').in_(['check_in', 'check_out']),
}, depends=['state', 'party'], context={'party': Eval('party')})
cancellation_policy = fields.Many2One('hotel.policy.cancellation',
'Cancellation Policy')
'Cancellation Policy', states=STATES_CHECKIN)
currency = fields.Many2One('currency.currency', 'Currency',
required=True, states={
'readonly': (Eval('state') != 'offer') |
@ -177,22 +177,22 @@ class Booking(Workflow, ModelSQL, ModelView):
invoice_method = fields.Selection(INVOICE_METHOD, 'Invoice Method',
required=False, states=STATES_CONFIRMED)
satisfaction = fields.Selection(SATISFACTION, 'Satisfaction')
media = fields.Selection(MEDIA, 'Media', states=STATES_PROCESSING,
media = fields.Selection(MEDIA, 'Media', states=STATES_CHECKIN,
help="Media from booking coming from.")
media_string = media.translated('media')
plan = fields.Selection(PLAN, 'Commercial Plan', states=STATES_PROCESSING,
plan = fields.Selection(PLAN, 'Commercial Plan', states=STATES_CHECKIN,
help="Plans offered by hotel and selected by guest for booking.")
plan_string = plan.translated('plan')
source_contact = fields.Selection(SOURCE, 'Source Contact',
states=STATES_PROCESSING,
states=STATES_CHECKIN,
help="Advertising source that create booking opportunity by guest.")
source_contact_string = source_contact.translated('source_contact')
comments = fields.Text('Comments', states=STATES_PROCESSING)
comments = fields.Text('Comments', states=STATES_CHECKIN)
segment = fields.Selection(SEGMENT, 'Tourism Segment',
states=STATES_PROCESSING)
states=STATES_CHECKIN)
segment_string = segment.translated('segment')
guarantee = fields.Selection(GUARANTEE, 'Guarantee',
states=STATES_PROCESSING)
states=STATES_CHECKIN)
guarantee_string = guarantee.translated('guarantee')
untaxed_amount = fields.Function(fields.Numeric('Untaxed Amount',
digits=(16, 2), depends=['lines']), 'get_untaxed_amount')
@ -206,7 +206,7 @@ class Booking(Workflow, ModelSQL, ModelView):
booker = fields.Many2One('party.party', 'Booker', states={'readonly': True})
created_channel = fields.DateTime('Created Channel', states={'readonly': True})
vouchers = fields.Many2Many('hotel.booking-account.voucher', 'booking',
'voucher', 'Vouchers', states=STATES_PROCESSING, domain=[
'voucher', 'Vouchers', states=STATES_CHECKIN, domain=[
], depends=['party'])
vip = fields.Boolean('V.I.P. Customer', states=STATES)
vehicles_num = fields.Integer('Vehicles Number', states=STATES,
@ -680,45 +680,51 @@ class BookingLine(ModelSQL, ModelView):
booking = fields.Many2One('hotel.booking', 'Booking',
ondelete='CASCADE', select=True)
room = fields.Many2One('hotel.room', 'Room', select=True, states={
'required': Eval('state') == 'confirmed',
'required': Eval('registration_state') == 'check_in',
'readonly': Eval('registration_state') == 'check_in',
})
arrival_date = fields.Date('Arrival Date', required=True)
departure_date = fields.Date('Departure Date', required=True)
arrival_date = fields.Date('Arrival Date', required=True,
states=STATES_CHECKIN)
departure_date = fields.Date('Departure Date', required=True,
states=STATES_CHECKIN)
product = fields.Many2One('product.product', 'Product',
select=True, domain=[
('template.type', '=', 'service'),
('template.kind', '=', 'accommodation'),
], required=True)
], required=True, states=STATES_CHECKIN)
unit_price = fields.Numeric('Unit Price', digits=(16, 4),
states={
'required': Bool(Eval('product')),
'readonly': Eval('registration_state') == 'check_in',
})
uom = fields.Many2One('product.uom', 'UOM', readonly=True)
main_guest = fields.Many2One('party.party', 'Main Guest', select=True,
states={
'required': Eval('state').in_(['check_in', 'check_out'])
'required': Eval('registration_state') == 'check_in',
'readonly': Eval('registration_state') == 'check_in',
}
)
state = fields.Selection(STATE, 'State')
contact = fields.Char('Contact')
contact = fields.Char('Contact', states=STATES_CHECKIN)
num_children = fields.Function(fields.Integer('No. Children'),
'get_num_children')
'get_num_children')
nights_quantity = fields.Function(fields.Integer('Nights'),
'get_nights_quantity')
host_quantity = fields.Integer('Host')
'get_nights_quantity')
host_quantity = fields.Integer('Host', states=STATES_CHECKIN)
unit_digits = fields.Function(fields.Integer('Unit Digits'), 'get_unit_digits')
notes = fields.Text('Notes')
total_amount = fields.Function(fields.Numeric('Total Amount',
digits=(16, 2)), 'get_total_amount')
digits=(16, 2)), 'get_total_amount')
total_commission = fields.Function(fields.Numeric('Channel Commission',
digits=(16, 2)), 'get_channel_commission')
guests = fields.One2Many('hotel.booking.guest', 'booking_line', 'Guests')
operation = fields.Many2One('hotel.operation', 'Operation')
nationality = fields.Many2One('party.nationality', 'Nationality')
digits=(16, 2)), 'get_channel_commission')
guests = fields.One2Many('hotel.booking.guest', 'booking_line', 'Guests',
states=STATES_CHECKIN)
operation = fields.Many2One('hotel.operation', 'Operation', readonly=True)
nationality = fields.Many2One('party.nationality', 'Nationality', states=STATES_CHECKIN)
origin_country = fields.Many2One('party.nationality', 'Origin Country',
select=True)
select=True, states=STATES_CHECKIN)
target_country = fields.Many2One('party.nationality', 'Target Country',
select=True)
select=True, states=STATES_CHECKIN)
registration_state = fields.Selection(REGISTRATION_STATE,
'Registration State', readonly=True)
@ -734,14 +740,14 @@ class BookingLine(ModelSQL, ModelView):
'invisible': Eval('state') == 'confirmed' and
Eval('registration_state').in_(['check_in', 'check_out']),
},
'check_out': {
'invisible': Eval('state') == 'confirmed' and
Eval('registration_state') == 'check_out',
}})
# 'check_out': {
# 'invisible': Eval('state') != 'check_in' and
# Eval('registration_state') == 'check_out',
# }
})
@classmethod
def write(cls, *args):
lines, vals = args[0], args[-1]
for line in lines:
if not line.operation:
@ -1065,12 +1071,12 @@ class SelectRoomsAsk(ModelView):
('template.accommodation_capacity', '>=', self.accommodation.accommodation_capacity)
])
rooms_ids = [t.room.id for t in room_templates]
rooms_available_ids = Operation.get_available_rooms(
self.arrival_date,
self.departure_date,
rooms_ids=rooms_ids
)
return rooms_available_ids

View File

@ -53,7 +53,7 @@ INVOICE_STATES = [
COMPLEMENTARY = [
('', ''),
('in_house', 'In House'),
('courtesy', 'courtesy')
('courtesy', 'Courtesy')
]
_ZERO = Decimal('0.00')
@ -116,7 +116,7 @@ class Operation(Workflow, ModelSQL, ModelView):
pending_payment = fields.Function(fields.Numeric('Pending Payment',
digits=(16, 2)), 'get_pending_payment')
notes = fields.Text('Notes', select=True, states=STATES_OP)
complementary = fields.Boolean('complementary', states=STATES_OP)
complementary = fields.Boolean('Complementary', states=STATES_OP)
type_complementary = fields.Selection(COMPLEMENTARY, 'Type Complementary', states={
'invisible': ~Bool(Eval('complementary')),
'required': Bool(Eval('complementary')),

View File

@ -24,6 +24,12 @@ class ServiceKind(ModelSQL, ModelView):
name = fields.Char('Name', select=True, required=True)
product = fields.Many2One('product.product', 'Product')
salable = fields.Boolean('Salable')
category = fields.Selection([
('breakfast', 'Breakfast'),
('restaurant', 'Restaurant'),
('laundry', 'Laundry'),
('spa', 'Spa'),
], 'Category')
class Service(Workflow, ModelSQL, ModelView):
@ -298,7 +304,11 @@ class ServiceReport(CompanyReport):
class CreateDailyServicesStart(ModelView):
'Create Daily Services Start'
__name__ = 'hotel.daily_services.start'
kind = fields.Many2One('hotel.service.kind', 'Kind', required=True)
kind = fields.Many2One('hotel.service.kind', 'Kind', required=True,
domain=[
('category', '=', 'breakfast'),
('product', '!=', None)
])
date = fields.Date('Date', required=True)
company = fields.Many2One('company.company', 'Company', required=True)
description = fields.Char('Description')
@ -336,17 +346,18 @@ class CreateDailyServices(Wizard):
'kind': self.start.kind.id,
}])
Service.open([service])
if self.start.kind.product:
for op in operations:
for guest in op.guests:
lines_to_create.append({
'service': service.id,
'room': op.room.id,
'guest': guest.id,
'product': self.start.kind.product.id,
'quantity': 1,
})
if lines_to_create:
ServiceLine.create(lines_to_create)
product = self.start.kind.product
for op in operations:
if not op.breakfast_included:
continue
for guest in op.guests:
lines_to_create.append({
'service': service.id,
'room': op.room.id,
'guest': guest.id,
'product': product.id,
'quantity': 1,
})
if lines_to_create:
ServiceLine.create(lines_to_create)
return 'end'

View File

@ -4,7 +4,6 @@ this repository contains the full copyright notices and license terms. -->
<tree>
<field name="product"/>
<button name="check_in" string="Check In" />
<button name="check_out" string="Check Out"/>
<field name="main_guest"/>
<field name="room"/>
<field name="nights_quantity"/>
@ -15,4 +14,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="host_quantity"/>
<field name="registration_state"/>
<field name="operation"/>
<!-- <button name="check_out" string="Check Out"/> -->
</tree>

View File

@ -26,6 +26,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="add_default_charges"/>
<label name="taxes_exception"/>
<field name="taxes_exception"/>
<label name="breakfast_included"/>
<field name="breakfast_included"/>
<notebook>
<page string="Lines" id="lines">
<field name="lines" colspan="4"/>

View File

@ -8,4 +8,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="salable"/>
<label name="product"/>
<field name="product"/>
<label name="category"/>
<field name="category"/>
</form>

View File

@ -5,4 +5,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="name"/>
<field name="product"/>
<field name="salable"/>
<field name="category"/>
</tree>