mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
58 lines
2.0 KiB
Python
Executable File
58 lines
2.0 KiB
Python
Executable File
# Copyright 2019 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
import json
|
|
from datetime import datetime
|
|
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 Gets the current business date/time. (MANDATORY)
|
|
utc_s = '+01:00'
|
|
# TODO Need know UTC in the machine/hotel
|
|
json_response = {
|
|
'dateTime': datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") + utc_s
|
|
}
|
|
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 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 a stay.
|
|
# Addition will be ok if the returned stay has ID. (MANDATORY)
|
|
_logger.info('ROOMMATIK Check-IN')
|
|
apidata = self.env['hotel.checkin.partner']
|
|
return apidata.rm_checkin_partner(stay)
|
|
|
|
@api.model
|
|
def rm_get_stay(self, check_in_code):
|
|
# RoomMatik API Gets stay information through check-in code
|
|
# (if code is related to a current stay)
|
|
# (MANDATORY for check-out kiosk)
|
|
apidata = self.env['hotel.checkin.partner']
|
|
# Debug Stop -------------------
|
|
# import wdb; wdb.set_trace()
|
|
# Debug Stop -------------------
|
|
return apidata.rm_get_stay(check_in_code)
|