From 73e895ed79fe1c425ce49dde119ab2981dea0419 Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Wed, 3 Apr 2019 18:27:55 +0200 Subject: [PATCH] [IMP] Roommatic get reservation --- hotel_roommatik/models/inherited_hotel_folio.py | 7 ++++++- hotel_roommatik/models/roommatik.py | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hotel_roommatik/models/inherited_hotel_folio.py b/hotel_roommatik/models/inherited_hotel_folio.py index e5f068aad..dce44af48 100755 --- a/hotel_roommatik/models/inherited_hotel_folio.py +++ b/hotel_roommatik/models/inherited_hotel_folio.py @@ -3,6 +3,8 @@ import json from odoo import api, models +import logging +_logger = logging.getLogger(__name__) class HotelFolio(models.Model): @@ -13,8 +15,8 @@ class HotelFolio(models.Model): def rm_get_reservation(self, Code): # BÚSQUEDA DE RESERVA POR LOCALIZADOR folio_res = self.env['hotel.folio'].search([('id', '=', Code)]) - json_response = dict() if any(folio_res): + _logger.info('ROOMMATIK serving Folio: %s', folio_res.id) folio_lin = folio_res.room_lines json_response = { 'Id': folio_res.id, @@ -33,6 +35,9 @@ class HotelFolio(models.Model): 'RoomTypeName': line.room_type_id.name, 'RoomName': line.room_id.name, }) + else: + _logger.info('ROOMMATIK Not Found Folio search %s', Code) + json_response = {'Error': 'Not Found ' + str(Code)} json_response = json.dumps(json_response) return json_response diff --git a/hotel_roommatik/models/roommatik.py b/hotel_roommatik/models/roommatik.py index a1ab6c60e..3cffff3c9 100755 --- a/hotel_roommatik/models/roommatik.py +++ b/hotel_roommatik/models/roommatik.py @@ -7,12 +7,13 @@ from odoo import api, models import logging _logger = logging.getLogger(__name__) + class RoomMatik(models.Model): _name = 'roommatik.api' @api.model def rm_get_date(self): - # RoomMatik API FECHA/HORA + # RoomMatik API Gets the current business date/time. (MANDATORY) utc_s = '+01:00' # TODO Need know UTC in the machine/hotel json_response = { @@ -21,16 +22,25 @@ class RoomMatik(models.Model): json_response = json.dumps(json_response) return json_response + @api.model + def rm_get_reservation(self, reservation_code): + # RoomMatik Gets a reservation ready for check-in + # through the provided code. (MANDATORY) + apidata = self.env['hotel.folio'] + return apidata.rm_get_reservation(reservation_code) + @api.model def rm_add_customer(self, customer): - # RoomMatik API CREACIÓN DE CLIENTE + # RoomMatik API Adds a new PMS customer through the provided parameters + # Addition will be ok if the returned customer has ID. (MANDATORY) _logger.info('ROOMMATIK Customer Creation') apidata = self.env['res.partner'] return apidata.rm_add_customer(customer) @api.model def rm_checkin_partner(self, stay): - # RoomMatik API CHECK-IN + # RoomMatik API Check-in a stay. + # Addition will be ok if the returned stay has ID. (MANDATORY) _logger.info('ROOMMATIK Check-IN') apidata = self.env['hotel.folio'] return apidata.rm_checkin_partner(stay)