diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index ff5e305fb..ad112e417 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -866,9 +866,13 @@ class HotelReservation(models.Model): @api.multi def action_cancel(self): for record in self: + cancel_reason = 'intime' if self._context.get("no_penalty", False) \ + else record.compute_cancelation_reason() + if self._context.get("no_penalty", False): + _logger.info("///MODIFIED RESERVATION - NO PENALTY") record.write({ 'state': 'cancelled', - 'cancelled_reason': record.compute_cancelation_reason() + 'cancelled_reason': cancel_reason }) record._compute_cancelled_discount() if record.splitted: diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index cc6eb5173..7a2098fa4 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -306,6 +306,7 @@ class HotelReservationImporter(Component): rcode = str(book['reservation_code']) crcode = str(book['channel_reservation_code']) \ if book['channel_reservation_code'] else 'undefined' + rcode_modified = str(book['reservation_code']) # Can't process failed reservations # (for example set a invalid new reservation and receive in @@ -336,6 +337,21 @@ class HotelReservationImporter(Component): if reserv_bind: folio_id = reserv_bind.folio_id + if rcode_modified: + if book['was_modified'] and rcode in book['modified_reservations']: + continue + else: + reservations = self.env['channel.hotel.reservation'].search([ + ('external_id', 'in', book['modified_reservations']), + ('backend_id', '=', self.backend_record.id), + ('state', '!=', 'cancelled') + ]) + if reservations: + reservations.with_context({ + 'connector_no_export': True, + 'ota_limits': False, + 'no_penalty': True}).action_cancel() + # Need update reservations? reservs_processed = False reservs_binds = channel_reserv_obj.search([