diff --git a/hotel_roommatik/__init__.py b/hotel_roommatik/__init__.py new file mode 100755 index 000000000..0650744f6 --- /dev/null +++ b/hotel_roommatik/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hotel_roommatik/__manifest__.py b/hotel_roommatik/__manifest__.py new file mode 100755 index 000000000..a26f5833b --- /dev/null +++ b/hotel_roommatik/__manifest__.py @@ -0,0 +1,27 @@ +# Copyright 2018 Jose Luis Algara (Alda hotels) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Hotel RoomMatik', + 'description': """ + Integration of Hootel with the RoomMatik kiosk""", + 'summary': """ + The integration of Hootel with the RoomMatik kiosk. + A series of requests/responses that provide the basic + information needed by the kiosk.""", + 'version': '11.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Jose Luis Algara (Alda hotels) ', + 'website': 'https://www.aldahotels.com', + 'category': 'Generic Modules/Hotel Management', + 'depends': [ + 'hotel', + 'partner_contact_gender', + 'partner_second_lastname', + 'partner_contact_birthdate' + ], + 'data': [ + ], + 'demo': [ + ], +} diff --git a/hotel_roommatik/models/__init__.py b/hotel_roommatik/models/__init__.py new file mode 100755 index 000000000..9432fd559 --- /dev/null +++ b/hotel_roommatik/models/__init__.py @@ -0,0 +1,3 @@ +from . import inherited_hotel_folio +from . import inherited_res_partner +from . import roommatik diff --git a/hotel_roommatik/models/inherited_hotel_folio.py b/hotel_roommatik/models/inherited_hotel_folio.py new file mode 100755 index 000000000..e5f068aad --- /dev/null +++ b/hotel_roommatik/models/inherited_hotel_folio.py @@ -0,0 +1,38 @@ +# Copyright 2018 Jose Luis Algara (Alda hotels) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json +from odoo import api, models + + +class HotelFolio(models.Model): + + _inherit = 'hotel.folio' + + @api.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): + folio_lin = folio_res.room_lines + json_response = { + 'Id': folio_res.id, + 'Arrival': folio_lin[0]['checkin'], + 'Departure': folio_lin[0]['checkout'], + 'Deposit': folio_res.amount_total, + } + for i, line in enumerate(folio_lin): + json_response.setdefault('Rooms', [i]).append({ + 'Id': line.id, + 'Adults': line.adults, + # Need a function (Clean and no Checkin) + 'IsAvailable': 0, + 'Price': line.price_total, + 'RoomTypeId': line.room_type_id.id, + 'RoomTypeName': line.room_type_id.name, + 'RoomName': line.room_id.name, + }) + json_response = json.dumps(json_response) + + return json_response diff --git a/hotel_roommatik/models/inherited_res_partner.py b/hotel_roommatik/models/inherited_res_partner.py new file mode 100755 index 000000000..6ce0ff185 --- /dev/null +++ b/hotel_roommatik/models/inherited_res_partner.py @@ -0,0 +1,130 @@ +# Copyright 2018 Jose Luis Algara (Alda hotels) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json +from odoo import _, api, fields, models +from datetime import datetime + + +class ResPartner(models.Model): + + _inherit = 'res.partner' + + @api.model + def rm_add_customer(self, customer): + # CREACIÓN DE CLIENTE + partnername = customer['LastName1'] + ' ' + customer['LastName2'] + ' ' + customer['FirstName'] + partner_res = self.env['res.partner'].search( + [('name', '=', partnername)]) + # Need a smart search function here (Check name, document, mail) return unique or null customer. + + json_response = dict() + if any(partner_res): + json_response = { + "Id": partner_res.id, + "FirstName": partner_res.firstname, + "LastName1": partner_res.lastname, + "LastName2": partner_res.lastname2, + "Birthday": partner_res.birthdate_date, + "Sex": partner_res.gender, + "IdentityDocument": [{ + "Number": "Null", + "Type": "Null", + "ExpiryDate": "dateTime", + "ExpeditionDate": "dateTime", + "Address": [{ + "Nationality": "Null", + "Country": partner_res.country_id.name, + "ZipCode": partner_res.zip, + "City": partner_res.city, + "Street": partner_res.street, + "House": "Null", + "Flat": "Null", + "Number": "Null", + "Province": partner_res.state_id.name, + }], + }], + "Contact": [{ + "Telephone": partner_res.phone, + "Fax": "Null", + "Mobile": partner_res.mobile, + "Email": partner_res.email, + }] + } + else: + # Create new customer + json_response = {'Id': 0} + + # Check Sex string + if customer['Sex'] not in {'male', 'female'}: + customer['Sex'] = '' + + # Check state_id + city_srch = self.env['res.country.state'].search([ + ('name', 'ilike', + customer['IdentityDocument'][0]['Address'][0]['Province'])]) + + # Create Street2 + street_2 = 'Nº ' + customer['IdentityDocument'][0]['Address'][0]['House'] + street_2 += ', ' + customer['IdentityDocument'][0]['Address'][0]['Flat'] + street_2 += ', ' + customer['IdentityDocument'][0]['Address'][0]['Number'] + + # Debug Stop ------------------- + #import wdb; wdb.set_trace() + # Debug Stop ------- + + # Check birthdate_date + # Here need to convert birthdate_date to '%d%m%Y' fomat + + write_custumer = self.create({ + 'firstname': customer['FirstName'], + 'lastname': customer['LastName1'], + 'lastname2': customer['LastName2'], + 'birthdate_date': datetime.strptime( + customer['Birthday'], '%d%m%Y'), + 'gender': customer['Sex'], + 'zip': customer['IdentityDocument'][0]['Address'][0]['ZipCode'], + 'city': customer['IdentityDocument'][0]['Address'][0]['City'], + 'street': customer['IdentityDocument'][0]['Address'][0]['Street'], + 'street2': street_2, + 'state_id': city_srch.id, + 'phone': customer['Contact'][0]['Telephone'], + 'mobile': customer['Contact'][0]['Mobile'], + 'email': customer['Contact'][0]['Email'], + }) + + + json_response = {'Id': write_custumer.id} + + # Id: será 0 en la solicitud y será diferente de 0 si el cliente se ha creado + # correctamente en el PMS. + # FirstName: nombre. + # LastName1: primer apellido. + # LastName2: segundo apellido. + # Birthday: fecha de nacimiento. + # Sex: sexo. Puede ser “M” para masculino o “F” para femenino. + # IdentityDocument: documento de identidad, formado por los siguientes + # valores: + # o Number: número de documento. + # o Type: tipo de documento. Puede ser: + # ▪ C: permiso de conducir. + # ▪ X: permiso de residencia europeo. + # ▪ D: DNI. + # ▪ I: documento de identidad. + # ▪ P: pasaporte. + # ▪ N: permiso de residencia español. + # o Expedition: fecha de expedición. + # o Expiration: fecha de caducidad. + # Address: dirección, formada por los siguientes valores: + # o City: ciudad. + # o Country: país (código ISO 3). + # o Flat: piso. + # o Nationality: nacionalidad (código ISO 3). + # o Number: número. + # o StateOrProvince: estado o provincia. + # o Street: calle. + # o ZipCode: código postal. + + json_response = json.dumps(json_response) + + return json_response diff --git a/hotel_roommatik/models/roommatik.py b/hotel_roommatik/models/roommatik.py new file mode 100755 index 000000000..09c6594ea --- /dev/null +++ b/hotel_roommatik/models/roommatik.py @@ -0,0 +1,23 @@ +# Copyright 2019 Jose Luis Algara (Alda hotels) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json +from datetime import datetime +from odoo import api, models + + +class RoomMatik(models.Model): + _name = 'roommatik.api' + + @api.model + def rm_get_date(self): + # FECHA/HORA + # Need know UTC in the machine/hotel + utc_s = '+01:00' + json_response = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") + utc_s + json_response = json.dumps(json_response) + return json_response + + # Debug Stop ------------------- + # import wdb; wdb.set_trace() + # Debug Stop ------------------- diff --git a/hotel_roommatik/static/description/icon.png b/hotel_roommatik/static/description/icon.png new file mode 100755 index 000000000..2f06baf55 Binary files /dev/null and b/hotel_roommatik/static/description/icon.png differ