Minor fix
This commit is contained in:
parent
d1c3dd61cb
commit
ebda46efaf
|
@ -147,7 +147,7 @@ class RatePlan(Workflow, ModelSQL, ModelView):
|
|||
Get the best available rate for the context:::
|
||||
price_list: Required
|
||||
accommodation: Required (product)
|
||||
Return sale price taxed for accomodation
|
||||
Return sale price taxed for accommodation
|
||||
"""
|
||||
PriceList = Pool().get('product.price_list')
|
||||
res = accommodation.sale_price_taxed
|
||||
|
|
47
room.py
47
room.py
|
@ -1,6 +1,7 @@
|
|||
# This file is part of Presik. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from datetime import datetime, date
|
||||
import copy
|
||||
from datetime import datetime, date, timedelta
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields
|
||||
from trytond.pyson import Eval
|
||||
|
@ -163,10 +164,52 @@ class Room(Workflow, ModelSQL, ModelView):
|
|||
def inspected(cls, records):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def get_stock_accomodations(cls, acco_ids=None):
|
||||
dom = []
|
||||
# acco_ids == [product.id, ...]
|
||||
if acco_ids:
|
||||
dom.append(
|
||||
('main_accommodation.products', 'in', acco_ids)
|
||||
)
|
||||
rooms = cls.search(dom)
|
||||
accos = {}
|
||||
for room in rooms:
|
||||
product = room.main_accommodation.products[0]
|
||||
try:
|
||||
accos[product.id].append(1)
|
||||
except:
|
||||
accos[product.id] = [1]
|
||||
return accos
|
||||
|
||||
@classmethod
|
||||
def get_faster_availability(cls, start_date, end_date, accos):
|
||||
Occupancy = Pool().get('hotel.folio.occupancy')
|
||||
delta = range((end_date - start_date).days)
|
||||
range_dates = [
|
||||
start_date + timedelta(days=dt)
|
||||
for dt in delta
|
||||
]
|
||||
fmt_dates = [str(dt) for dt in range_dates]
|
||||
occupancy = Occupancy.search_read([
|
||||
('occupancy_date', 'in', fmt_dates),
|
||||
('folio.product', 'in', accos),
|
||||
], fields_names=['folio.product', 'occupancy_date'])
|
||||
res = {}
|
||||
stock = cls.get_stock_accomodations(accos)
|
||||
for acc_id in accos:
|
||||
res[acc_id] = {}
|
||||
for dt in range_dates:
|
||||
res[acc_id][dt] = copy.deepcopy(stock[acc_id])
|
||||
|
||||
for occ in occupancy:
|
||||
product_id = occ['folio.']['product']
|
||||
res[product_id][occ['occupancy_date']].append(-1)
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def available_by_classification(cls, start_date, end_date, rate_plan=None):
|
||||
pool = Pool()
|
||||
# Classification = pool.get('hotel.room.classification')
|
||||
Folio = pool.get('hotel.folio')
|
||||
RatePlan = pool.get('hotel.rate_plan')
|
||||
fmt = "%Y-%m-%d"
|
||||
|
|
Loading…
Reference in New Issue