[FIX] State on split Reservations

This commit is contained in:
Dario Lodeiros
2019-03-16 23:12:03 +01:00
parent f21a6b99d5
commit 81f8cc6460
3 changed files with 34 additions and 17 deletions

View File

@@ -389,9 +389,12 @@ class HotelReservation(models.Model):
if 'checkout' in vals:
vals['real_checkout'] = vals['checkout']
real_checkin = vals['real_checkin'] if 'real_checkin' in vals else record.real_checkin
real_checkout = vals['real_checkout'] if 'real_checkout' in vals else record.real_checkout
days_diff = (
fields.Date.from_string(checkout) - \
fields.Date.from_string(checkin)
fields.Date.from_string(real_checkout) - \
fields.Date.from_string(real_checkin)
).days
if self.compute_board_services(vals):
record.service_ids.filtered(lambda r: r.is_board_service == True).unlink()
@@ -410,7 +413,7 @@ class HotelReservation(models.Model):
if record.compute_price_out_vals(vals):
pricelist_id = vals['pricelist_id'] if 'pricelist_id' in vals else record.pricelist_id.id
record.update(record.prepare_reservation_lines(
checkin,
real_checkin,
days_diff,
pricelist_id,
vals=vals)) #REVISAR el unlink
@@ -418,7 +421,7 @@ class HotelReservation(models.Model):
for service in record.service_ids:
if service.product_id.per_day:
service.update(service.prepare_service_lines(
dfrom=checkin,
dfrom=real_checkin,
days=days_diff,
per_person=service.product_id.per_person,
persons=service.ser_room_line.adults,
@@ -756,7 +759,6 @@ class HotelReservation(models.Model):
@param self: object pointer
'''
_logger.info('confirm')
hotel_folio_obj = self.env['hotel.folio']
hotel_reserv_obj = self.env['hotel.reservation']
for record in self:
vals = {}
@@ -775,8 +777,10 @@ class HotelReservation(models.Model):
('id', '=', master_reservation.id),
('folio_id', '=', record.folio_id.id),
('id', '!=', record.id),
('state', '!=', 'confirm')
('state', 'not in', ('confirm', 'booking'))
])
if master_reservation.checkin_partner_ids:
record.update({'state': 'booking'})
splitted_reservs.confirm()
return True
@@ -1111,7 +1115,9 @@ class HotelReservation(models.Model):
'parent_reservation': parent_res.id,
'room_type_id': parent_res.room_type_id.id,
'discount': parent_res.discount,
'state': parent_res.state,
'reservation_line_ids': reservation_lines[1],
'preconfirm': False,
})
reservation_copy = self.env['hotel.reservation'].with_context({
'ignore_avail_restrictions': True}).create(vals)

View File

@@ -169,10 +169,12 @@ class HotelService(models.Model):
if self.compute_lines_out_vals(vals):
reservation = self.env['hotel.reservation'].browse(vals['ser_room_line'])
product = self.env['product.product'].browse(vals['product_id'])
checkin_dt = fields.Date.from_string(reservation.real_checkin)
checkout_dt = fields.Date.from_string(reservation.real_checkout)
nights = abs((checkout_dt - checkin_dt).days)
vals.update(self.prepare_service_lines(
dfrom=reservation.checkin,
days=reservation.nights,
dfrom=reservation.real_checkin,
days=nights,
per_person=product.per_person,
persons=reservation.adults,
old_day_lines=False,
@@ -195,9 +197,12 @@ class HotelService(models.Model):
reservations = self.env['hotel.reservation']
reservation = reservations.browse(vals['ser_room_line']) \
if 'ser_room_line' in vals else record.ser_room_line
checkin_dt = fields.Date.from_string(reservation.real_checkin)
checkout_dt = fields.Date.from_string(reservation.real_checkout)
nights = abs((checkout_dt - checkin_dt).days)
record.update(record.prepare_service_lines(
dfrom=reservation.checkin,
days=reservation.nights,
dfrom=reservation.real_checkin,
days=nights,
per_person=product.per_person,
persons=reservation.adults,
old_line_days=self.service_line_ids
@@ -272,9 +277,12 @@ class HotelService(models.Model):
if record.per_day and record.ser_room_line:
product = record.product_id
reservation = record.ser_room_line
checkin_dt = fields.Date.from_string(reservation.real_checkin)
checkout_dt = fields.Date.from_string(reservation.real_checkout)
nights = abs((checkout_dt - checkin_dt).days)
vals.update(record.prepare_service_lines(
dfrom=reservation.checkin,
days=reservation.nights,
dfrom=reservation.real_checkin,
days=nights,
per_person=product.per_person,
persons=reservation.adults,
old_line_days=record.service_line_ids))