mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Multiple commit
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
'partner_contact_birthdate'
|
||||
],
|
||||
'data': [
|
||||
'views/inherit_hotel_reservation.xml',
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from . import inherited_hotel_folio
|
||||
from . import inherited_hotel_checkin_partner
|
||||
from . import inherited_res_partner
|
||||
from . import inherited_hotel_room_type
|
||||
from . import roommatik
|
||||
from . import inherited_hotel_reservation
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2018 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
||||
# Copyright 2019 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import json
|
||||
@@ -12,11 +12,12 @@ class HotelFolio(models.Model):
|
||||
|
||||
@api.model
|
||||
def rm_checkin_partner(self, stay):
|
||||
# CHECK-IN
|
||||
_logger = logging.getLogger(__name__)
|
||||
# CHECK-IN
|
||||
reservation_rm = self.env['hotel.reservation'].search([('id', '=',
|
||||
stay['Code'])])
|
||||
# Need checkin?
|
||||
|
||||
total_chekins = reservation_rm.checkin_partner_pending_count
|
||||
if total_chekins > 0 and len(stay["Customers"]) <= total_chekins:
|
||||
_logger.info('ROOMMATIK checkin %s customer in %s Reservation.',
|
||||
@@ -61,6 +62,9 @@ class HotelFolio(models.Model):
|
||||
stay['Id'] = record.id
|
||||
json_response = stay
|
||||
except:
|
||||
# Debug Stop -------------------
|
||||
import wdb; wdb.set_trace()
|
||||
# Debug Stop -------------------
|
||||
json_response = {'Estate': 'Error not create Checkin'}
|
||||
_logger.error('ROOMMATIK writing %s in reservation: %s).',
|
||||
checkin_partner_val['document_number'],
|
||||
@@ -77,42 +81,42 @@ class HotelFolio(models.Model):
|
||||
|
||||
@api.model
|
||||
def rm_get_stay(self, code):
|
||||
# BUSQUEDA POR LOCALIZADOR
|
||||
reserva = self.search([('id', '=', code)])
|
||||
stay = {'Code': code}
|
||||
stay['Id'] = reserva.folio_id.id
|
||||
stay['Room'] = {}
|
||||
stay['Room']['Id'] = reserva.reservation_id.room_id.id
|
||||
stay['Room']['Name'] = reserva.reservation_id.room_id.name
|
||||
stay['RoomType'] = {}
|
||||
stay['RoomType']['Id'] = reserva.reservation_id.room_type_id.id
|
||||
stay['RoomType']['Name'] = reserva.reservation_id.room_type_id.name
|
||||
stay['RoomType']['GuestNumber'] = "xxxxxxx"
|
||||
stay['Arrival'] = (reserva.reservation_id.real_checkin +
|
||||
'T' + reserva.reservation_id.arrival_hour + ':00')
|
||||
stay['Departure'] = (reserva.reservation_id.real_checkout +
|
||||
'T' +
|
||||
reserva.reservation_id.departure_hour + ':00')
|
||||
stay['Customers'] = []
|
||||
for idx, cpi in enumerate(reserva.reservation_id.checkin_partner_ids):
|
||||
stay['Customers'].append({'Customer': {}})
|
||||
stay['Customers'][idx]['Customer'] = self.env[
|
||||
'res.partner'].rm_get_a_customer(cpi.partner_id.id)
|
||||
stay['TimeInterval'] = {}
|
||||
stay['TimeInterval']['Id'] = {}
|
||||
stay['TimeInterval']['Name'] = {}
|
||||
stay['TimeInterval']['Minutes'] = {}
|
||||
stay['Adults'] = reserva.reservation_id.adults
|
||||
stay['ReservationCode'] = {}
|
||||
stay['Total'] = reserva.reservation_id.price_total
|
||||
stay['Paid'] = (stay['Total'] -
|
||||
reserva.reservation_id.folio_pending_amount)
|
||||
stay['Outstanding'] = {}
|
||||
stay['Taxable'] = reserva.reservation_id.price_tax
|
||||
if any(reserva):
|
||||
stay = {'Code': reserva.reservation_id.localizator}
|
||||
stay['Id'] = reserva.folio_id.id
|
||||
stay['Room'] = {}
|
||||
stay['Room']['Id'] = reserva.reservation_id.room_id.id
|
||||
stay['Room']['Name'] = reserva.reservation_id.room_id.name
|
||||
stay['RoomType'] = {}
|
||||
stay['RoomType']['Id'] = reserva.reservation_id.room_type_id.id
|
||||
stay['RoomType']['Name'] = reserva.reservation_id.room_type_id.name
|
||||
stay['RoomType']['GuestNumber'] = "xxxxxxx"
|
||||
stay['Arrival'] = (reserva.reservation_id.real_checkin +
|
||||
'T' + reserva.reservation_id.arrival_hour + ':00')
|
||||
stay['Departure'] = (reserva.reservation_id.real_checkout +
|
||||
'T' +
|
||||
reserva.reservation_id.departure_hour + ':00')
|
||||
stay['Customers'] = []
|
||||
for idx, cpi in enumerate(reserva.reservation_id.checkin_partner_ids):
|
||||
stay['Customers'].append({'Customer': {}})
|
||||
stay['Customers'][idx]['Customer'] = self.env[
|
||||
'res.partner'].rm_get_a_customer(cpi.partner_id.id)
|
||||
stay['TimeInterval'] = {}
|
||||
stay['TimeInterval']['Id'] = {}
|
||||
stay['TimeInterval']['Name'] = {}
|
||||
stay['TimeInterval']['Minutes'] = {}
|
||||
stay['Adults'] = reserva.reservation_id.adults
|
||||
stay['ReservationCode'] = {}
|
||||
stay['Total'] = reserva.reservation_id.price_total
|
||||
stay['Paid'] = (stay['Total'] -
|
||||
reserva.reservation_id.folio_pending_amount)
|
||||
stay['Outstanding'] = {}
|
||||
stay['Taxable'] = reserva.reservation_id.price_tax
|
||||
|
||||
else:
|
||||
stay = {'Code': ""}
|
||||
|
||||
json_response = json.dumps(stay)
|
||||
|
||||
return json_response
|
||||
|
||||
# Debug Stop -------------------
|
||||
#import wdb; wdb.set_trace()
|
||||
# Debug Stop -------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2018 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
||||
# Copyright 2019 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import json
|
||||
@@ -25,19 +25,21 @@ class HotelFolio(models.Model):
|
||||
'Deposit': folio_res.amount_total,
|
||||
}
|
||||
for i, line in enumerate(folio_lin):
|
||||
total_chekins = folio_lin.checkin_partner_pending_count
|
||||
json_response.setdefault('Rooms', [i]).append({
|
||||
'Id': line.id,
|
||||
'Adults': line.adults,
|
||||
# Need a function (Clean and no Checkin)
|
||||
'IsAvailable': 0,
|
||||
'IsAvailable': True if total_chekins > 0 else False,
|
||||
# IsAvailable “false” Rooms not need check-in
|
||||
'Price': line.price_total,
|
||||
'RoomTypeId': line.room_type_id.id,
|
||||
'RoomTypeName': line.room_type_id.name,
|
||||
'RoomName': line.room_id.name,
|
||||
})
|
||||
# Debug Stop -------------------
|
||||
# import wdb; wdb.set_trace()
|
||||
# Debug Stop -------------------
|
||||
else:
|
||||
_logger.warning('ROOMMATIK Not Found Folio search %s', Code)
|
||||
json_response = {'Error': 'Not Found ' + str(Code)}
|
||||
json_response = json.dumps(json_response)
|
||||
|
||||
return json_response
|
||||
return json.dumps(json_response)
|
||||
|
||||
23
hotel_roommatik/models/inherited_hotel_reservation.py
Normal file
23
hotel_roommatik/models/inherited_hotel_reservation.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# 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, fields
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
import random
|
||||
|
||||
class HotelReservation(models.Model):
|
||||
|
||||
_inherit = 'hotel.reservation'
|
||||
|
||||
def _compute_localizator(self):
|
||||
random.seed(self.id)
|
||||
number = str(random.random())
|
||||
leters = "ABCEFGHJKL"
|
||||
locali = str(self.folio_id.id) + leters[int(number[11])]
|
||||
locali += number[2:10] + leters[int(number[12])]
|
||||
locali += str(self.id)
|
||||
self.localizator = locali
|
||||
return
|
||||
|
||||
localizator = fields.Char('Localizator', compute='_compute_localizator')
|
||||
49
hotel_roommatik/models/inherited_hotel_room_type.py
Normal file
49
hotel_roommatik/models/inherited_hotel_room_type.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# 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
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
|
||||
|
||||
class HotelRoomType(models.Model):
|
||||
|
||||
_inherit = "hotel.room.type"
|
||||
|
||||
@api.model
|
||||
def rm_get_all_room_type_rates(self):
|
||||
# types = self.env['hotel.room.type'].search(['active', '=', True])
|
||||
types = self.env['hotel.room.type'].search([])
|
||||
dfrom = datetime.now()
|
||||
dto = (dfrom + timedelta(hours=24))
|
||||
|
||||
room_type_rates = []
|
||||
for i, type in enumerate(types):
|
||||
frees = self.check_availability_room_type(dfrom, dto, type.id)
|
||||
if any(frees):
|
||||
room_type_rates.append({
|
||||
"RoomType": {
|
||||
"Id": type.id,
|
||||
"Name": type.product_id.name,
|
||||
"GuestNumber": type.get_capacity()
|
||||
},
|
||||
"TimeInterval": {
|
||||
"Id": "1",
|
||||
"Name": "1 day",
|
||||
"Minutes": "1440"
|
||||
},
|
||||
"Price": "",
|
||||
"IsAvailable": "",
|
||||
})
|
||||
|
||||
return room_type_rates
|
||||
|
||||
@api.model
|
||||
def rm_get_prices(self, start_date, time_interval, number_intervals, room_type, guest_number):
|
||||
# TODO: FALTA POR COMPLETO
|
||||
_logger = logging.getLogger(__name__)
|
||||
_logger.info('ROOMMATIK get prices date %s Room: %s for %s Guests',
|
||||
start_date,
|
||||
room_type,
|
||||
guest_number)
|
||||
return {'start_date': start_date, 'time_interval': time_interval, 'number_intervals': number_intervals}
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2018 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
||||
# Copyright 2019 Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import json
|
||||
@@ -59,7 +59,7 @@ class ResPartner(models.Model):
|
||||
street_2 = customer['Address']['House']
|
||||
street_2 += ' ' + customer['Address']['Flat']
|
||||
street_2 += ' ' + customer['Address']['Number']
|
||||
return {
|
||||
metadata = {
|
||||
'firstname': customer['FirstName'],
|
||||
'lastname': customer['LastName1'],
|
||||
'lastname2': customer['LastName2'],
|
||||
@@ -80,6 +80,7 @@ class ResPartner(models.Model):
|
||||
'IdentityDocument']['ExpeditionDate'],
|
||||
"%d%m%Y").date(),
|
||||
}
|
||||
return {k: v for k, v in metadata.items() if v is not ""}
|
||||
|
||||
def rm_get_a_customer(self, customer):
|
||||
# Prepare a Customer for RoomMatik
|
||||
|
||||
@@ -51,7 +51,24 @@ class RoomMatik(models.Model):
|
||||
# (if code is related to a current stay)
|
||||
# (MANDATORY for check-out kiosk)
|
||||
apidata = self.env['hotel.checkin.partner']
|
||||
return apidata.rm_get_stay(check_in_code)
|
||||
|
||||
@api.model
|
||||
def rm_get_all_room_type_rates(self):
|
||||
# Gets the current room rates and availability. (MANDATORY)
|
||||
# return ArrayOfRoomTypeRate
|
||||
_logger.info('ROOMMATIK Get Rooms and Rates')
|
||||
apidata = self.env['hotel.room.type']
|
||||
return apidata.rm_get_all_room_type_rates()
|
||||
|
||||
@api.model
|
||||
def rm_get_prices(self, start_date, time_interval, number_intervals, room_type, guest_number):
|
||||
# Gets some prices related to different dates of the same stay.
|
||||
# return ArrayOfDecimal
|
||||
_logger.info('ROOMMATIK Get Prices')
|
||||
apidata = self.env['hotel.room.type']
|
||||
return apidata.rm_get_prices(start_date, time_interval, number_intervals, room_type, guest_number)
|
||||
|
||||
# Debug Stop -------------------
|
||||
# import wdb; wdb.set_trace()
|
||||
# Debug Stop -------------------
|
||||
return apidata.rm_get_stay(check_in_code)
|
||||
|
||||
17
hotel_roommatik/views/inherit_hotel_reservation.xml
Normal file
17
hotel_roommatik/views/inherit_hotel_reservation.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- Hotel Settings -->
|
||||
<data>
|
||||
<!-- Inherit view to add 'localizator' in Reservation Form -->
|
||||
<record id="roommatik_code_reservation_form" model="ir.ui.view">
|
||||
<field name="name">roommatik.reservation_form</field>
|
||||
<field name="model">hotel.reservation</field>
|
||||
<field name="inherit_id" ref="hotel.hotel_reservation_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='reservation_type']" position="after">
|
||||
<field name="localizator" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user