This commit is contained in:
oscar alvarez 2022-03-22 18:37:09 -05:00
parent e30c38f8fe
commit bbb8925a09
9 changed files with 54 additions and 26 deletions

View File

@ -194,7 +194,7 @@ class Booking(Workflow, ModelSQL, ModelView):
},
'bill_to_channel': {
'invisible': ~Eval('channel'),
'readonly': Eval('channel_paymode') != 'ota_collect',
'readonly': (Eval('channel_paymode') != 'ota_collect') | Eval('channel_invoice', True),
},
})
@ -212,6 +212,22 @@ class Booking(Workflow, ModelSQL, ModelView):
default['booking_date'] = datetime.now()
return super(Booking, cls).copy(bookings, default=default)
@classmethod
def search_rec_name(cls, name, clause):
_, operator, value = clause
if operator.startswith('!') or operator.startswith('not '):
bool_op = 'AND'
else:
bool_op = 'OR'
domain = [
bool_op,
('number', operator, value),
('ota_booking_code', operator, value),
('party.name', operator, value),
('contact', operator, value),
]
return domain
@staticmethod
def default_currency():
Company = Pool().get('company.company')
@ -249,6 +265,12 @@ class Booking(Workflow, ModelSQL, ModelView):
res += line.num_children
return res
@fields.depends('ota_booking_code', 'lines')
def on_change_ota_booking_code(self):
if self.ota_booking_code:
for line in self.lines:
line.reference = self.ota_booking_code
@fields.depends('party', 'price_list', 'lines')
def on_change_party(self):
if self.party:
@ -422,7 +444,6 @@ class Booking(Workflow, ModelSQL, ModelView):
raise UserError(gettext('hotel.msg_customer_is_required'))
bk = fo.booking
print(' fo.booking ....', fo.booking)
agent_id = bk.channel.agent.id if bk.channel else None
if party.id not in res.keys():
# Add room product to sale
@ -481,8 +502,6 @@ class Booking(Workflow, ModelSQL, ModelView):
'reference': charge.folio.registration_card,
'lines': [],
}
# if invoice_party_id != bk.party.id:
# else:
res[invoice_party_id]['lines'].append({
'description': ' | '.join([
@ -817,13 +836,6 @@ class Booking(Workflow, ModelSQL, ModelView):
res += line.total_amount
return res
# def get_occupancies(self, name):
# occupancies = set()
# for line in self.lines:
# if line.occupancy_line:
# occupancies.add(line.occupancy_line.id)
# return list(occupancies)
def get_channel_commission(self, name):
res = sum(line.commission_amount for line in self.lines if
line.commission_amount)
@ -978,6 +990,8 @@ class SelectRooms(Wizard):
values = {
'booking': booking.id,
'product': product.id,
'reference': booking.ota_booking_code,
'contact': booking.contact,
'room': room.id,
'arrival_date': self.start.arrival_date,
'departure_date': self.start.departure_date,

View File

@ -57,14 +57,17 @@ _ZERO = Decimal('0')
class Folio(ModelSQL, ModelView):
'Folio'
__name__ = 'hotel.folio'
booking = fields.Many2One('hotel.booking', 'Booking', ondelete='CASCADE',
select=True)
registration_card = fields.Char('Registration Card', readonly=True,
select=True, help="Unique sequence for card guest registration.")
room = fields.Many2One('hotel.room', 'Room', select=True, states={
STATES = {
'required': Eval('registration_state') == 'check_in',
'readonly': Eval('registration_state') == 'check_in',
})
}
booking = fields.Many2One('hotel.booking', 'Booking', ondelete='CASCADE',
select=True)
reference = fields.Char('Reference', states=STATES)
registration_card = fields.Char('Registration Card', readonly=True,
select=True, help="Unique sequence for card guest registration.")
room = fields.Many2One('hotel.room', 'Room', select=True,
states=STATES_CHECKIN)
arrival_date = fields.Date('Arrival Date', required=True,
states=STATES_CHECKOUT)
departure_date = fields.Date('Departure Date', required=True,
@ -83,10 +86,7 @@ class Folio(ModelSQL, ModelView):
'get_unit_price_w_tax')
uom = fields.Many2One('product.uom', 'UOM', readonly=True)
main_guest = fields.Many2One('party.party', 'Main Guest', select=True,
states={
'required': Eval('registration_state') == 'check_in',
'readonly': Eval('registration_state') == 'check_in',
}
states=STATES_CHECKIN
)
contact = fields.Char('Contact', states=STATES_CHECKIN)
num_children = fields.Function(fields.Integer('No. Children'),
@ -143,10 +143,11 @@ class Folio(ModelSQL, ModelView):
), 'on_change_with_room_amount')
stock_moves = fields.Many2Many('hotel.folio-stock.move', 'folio',
'move', 'Stock Moves', states={'readonly': True})
channel = fields.Function(fields.Many2One('hotel.channel', 'Channel'),
'get_channel')
@classmethod
def __setup__(cls):
# UPDATE hotel_folio SET nights_quantity=(departure_date-arrival_date)
super(Folio, cls).__setup__()
cls._check_modify_exclude = [
'nationality', 'origin_country', 'target_country',
@ -190,6 +191,7 @@ class Folio(ModelSQL, ModelView):
('registration_card', operator, value),
('product.name', operator, value),
('party.name', operator, value),
('reference', operator, value),
]
return domain
@ -246,6 +248,10 @@ class Folio(ModelSQL, ModelView):
if self.invoice_line:
return self.invoice_line.invoice.state
def get_channel(self, name=None):
if self.booking and self.booking.channel:
return self.booking.channel.id
def set_registration_number(self):
"""
Fill the number field for registration card with sequence
@ -875,8 +881,8 @@ class Migration(Report):
('arrival_date', '>=', start),
('arrival_date', '<=', end),
('main_guest', '!=', None),
('registration_state', 'in', ['check_in', 'check_out']),
('guests.party', '!=', None),
('registration_state', 'in', ['check_in', 'check_out']),
])
return report_context

Binary file not shown.

View File

@ -2,3 +2,4 @@
ALTER TABLE hotel_channel DROP COLUMN commission;
ALTER TABLE hotel_channel DROP COLUMN payment_method;
ALTER TABLE hotel_booking RENAME COLUMN party_seller TO channel;
UPDATE hotel_folio SET nights_quantity=(departure_date-arrival_date)

View File

@ -28,6 +28,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="breakfast_included"/>
<label name="unit_price_w_tax"/>
<field name="unit_price_w_tax"/>
<label name="reference"/>
<field name="reference"/>
<notebook colspan="6">
<page string="Charges" id="hotel_charges">
<field name="charges" colspan="4"/>

View File

@ -7,10 +7,13 @@ this repository contains the full copyright notices and license terms. -->
<field name="product" expand="1"/>
<field name="registration_card"/>
<field name="main_guest" expand="1"/>
<field name="contact"/>
<field name="nights_quantity"/>
<field name="arrival_date"/>
<field name="departure_date"/>
<field name="registration_state"/>
<field name="reference"/>
<field name="channel"/>
<field name="invoice_state"/>
<field name="unit_price"/>
<field name="total_amount"/>

View File

@ -30,6 +30,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="unit_price_w_tax"/>
<label name="room_amount"/>
<field name="room_amount"/>
<label name="reference"/>
<field name="reference"/>
<notebook colspan="6">
<page string="Charges" id="hotel_charges">
<field name="charges" colspan="4"/>

View File

@ -20,10 +20,10 @@ this repository contains the full copyright notices and license terms. -->
<field name="reason"/>
<label name="channel"/>
<field name="channel" widget="selection"/>
<label name="price_list"/>
<field name="price_list" widget="selection"/>
<label name="ota_booking_code"/>
<field name="ota_booking_code"/>
<label name="price_list"/>
<field name="price_list" widget="selection"/>
<button name="select_rooms" string="Select Rooms"
icon="tryton-open" colspan="4"/>
<button name="do_pay" string="Do Pay" icon="tryton-open"/>

View File

@ -6,8 +6,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="party" expand="1"/>
<field name="contact" expand="1"/>
<field name="booking_date" widget="date"/>
<field name="price_list"/>
<field name="channel" expand="1"/>
<field name="ota_booking_code"/>
<field name="media"/>
<field name="total_amount"/>
<field name="total_advance"/>