mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Roommatik integration
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
from . import inherited_hotel_folio
|
||||
from . import inherited_hotel_checkin_partner
|
||||
from . import inherited_res_partner
|
||||
from . import inherited_hotel_room_type
|
||||
|
||||
@@ -30,10 +30,14 @@ class HotelCheckinPartner(models.Model):
|
||||
'channel_type': 'virtualdoor',
|
||||
}
|
||||
reservation_rm = reservation_obj.create(vals)
|
||||
stay['ReservationCode'] = reservation_rm.localizator
|
||||
else:
|
||||
reservation_rm = self.env['hotel.reservation'].browse(
|
||||
stay['ReservationCode'])
|
||||
reservation_rm = self.env['hotel.reservation'].search([
|
||||
('localizator', '=', stay['ReservationCode'])
|
||||
])
|
||||
total_chekins = reservation_rm.checkin_partner_pending_count
|
||||
stay['Total'] = reservation_rm.folio_pending_amount
|
||||
stay['Paid'] = reservation_rm._computed_deposit_roommatik(stay['ReservationCode'])
|
||||
if total_chekins > 0 and len(stay["Customers"]) <= total_chekins:
|
||||
_logger.info('ROOMMATIK checkin %s customer in %s Reservation.',
|
||||
total_chekins,
|
||||
@@ -65,19 +69,21 @@ class HotelCheckinPartner(models.Model):
|
||||
record.id)
|
||||
record.action_on_board()
|
||||
stay['Id'] = record.id
|
||||
stay['Room'] = reservation_rm.room_id.id
|
||||
stay['Room'] = {}
|
||||
stay['Room']['Id'] = reservation_rm.room_id.id
|
||||
stay['Room']['Name'] = reservation_rm.room_id.name
|
||||
json_response = stay
|
||||
except Exception as e:
|
||||
error_name = 'Error not create Checkin '
|
||||
error_name += e.name
|
||||
json_response = {'Estate': error_name}
|
||||
json_response = {'State': error_name}
|
||||
_logger.error('ROOMMATIK writing %s in reservation: %s).',
|
||||
checkin_partner_val['partner_id'],
|
||||
checkin_partner_val['reservation_id'])
|
||||
return json_response
|
||||
|
||||
else:
|
||||
json_response = {'Estate': 'Error checkin_partner_pending_count \
|
||||
json_response = {'State': 'Error checkin_partner_pending_count \
|
||||
values do not match.'}
|
||||
_logger.error('ROOMMATIK checkin pending count do not match for \
|
||||
Reservation ID %s.', reservation_rm.id)
|
||||
@@ -93,10 +99,8 @@ class HotelCheckinPartner(models.Model):
|
||||
default_departure_hour = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_departure_hour')
|
||||
if any(checkin_partner):
|
||||
arrival = "%s %s:00" % (checkin_partner.enter_date.strftime(
|
||||
DEFAULT_ROOMMATIK_DATE_FORMAT), default_arrival_hour)
|
||||
departure = "%s %s:00" % (checkin_partner.exit_date.strftime(
|
||||
DEFAULT_ROOMMATIK_DATE_FORMAT), default_departure_hour)
|
||||
arrival = checkin_partner.enter_date or default_arrival_hour
|
||||
departure = checkin_partner.exit_date or default_departure_hour
|
||||
stay = {'Code': checkin_partner.id}
|
||||
stay['Id'] = checkin_partner.id
|
||||
stay['Room'] = {}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# Copyright 2019 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelFolio(models.Model):
|
||||
|
||||
_inherit = 'hotel.folio'
|
||||
@@ -52,8 +52,8 @@ class HotelRoomType(models.Model):
|
||||
@api.model
|
||||
def rm_get_prices(self, start_date, number_intervals,
|
||||
room_type, guest_number):
|
||||
start_date = fields.Datetime.from_string(start_date)
|
||||
end_date = start_date + timedelta(days=number_intervals)
|
||||
start_date = fields.Date.from_string(start_date)
|
||||
end_date = start_date + timedelta(days=int(number_intervals))
|
||||
dfrom = start_date.strftime(
|
||||
DEFAULT_ROOMMATIK_DATE_FORMAT)
|
||||
dto = end_date.strftime(
|
||||
@@ -64,7 +64,7 @@ class HotelRoomType(models.Model):
|
||||
rates = self.get_rate_room_types(
|
||||
room_type_ids=room_type.id,
|
||||
date_from=dfrom,
|
||||
days=number_intervals,
|
||||
days=int(number_intervals),
|
||||
partner_id=False)
|
||||
return [item['price'] for item in rates.get(room_type.id)]
|
||||
return []
|
||||
|
||||
@@ -76,9 +76,11 @@ class RoomMatik(models.Model):
|
||||
def rm_get_prices(self, start_date, number_intervals, room_type, guest_number):
|
||||
# Gets some prices related to different dates of the same stay.
|
||||
# return ArrayOfDecimal
|
||||
room_type = self.env['hotel.room.type'].browse(room_type)
|
||||
_logger.info('ROOMMATIK Get Prices')
|
||||
apidata = self.env['hotel.room.type']
|
||||
room_type = apidata.browse(int(room_type))
|
||||
_logger.info('ROOMMATIK Get Prices')
|
||||
if not room_type:
|
||||
return {'State': 'Error Room Type not Found'}
|
||||
return apidata.sudo().rm_get_prices(start_date, number_intervals, room_type, guest_number)
|
||||
|
||||
@api.model
|
||||
|
||||
Reference in New Issue
Block a user