Fix
This commit is contained in:
parent
dfdb619d35
commit
b80e05a4ef
|
@ -37,6 +37,7 @@ def register():
|
|||
product.PriceList,
|
||||
booking.Booking,
|
||||
booking.BookingDailyStart,
|
||||
booking.ManagerStart,
|
||||
housekeeping.Housekeeping,
|
||||
housekeeping.HousekeepingCleaningType,
|
||||
party.Party,
|
||||
|
@ -76,6 +77,7 @@ def register():
|
|||
booking.BookingForecastReport,
|
||||
booking.RoomsOccupancyReport,
|
||||
booking.BookingDailyReport,
|
||||
booking.ManagerReport,
|
||||
booking.BookingStatementReport,
|
||||
folio.Migration,
|
||||
folio.GuestsListReport,
|
||||
|
@ -92,6 +94,7 @@ def register():
|
|||
booking.RoomsOccupancy,
|
||||
booking.BookingDaily,
|
||||
booking.UpdateHolder,
|
||||
booking.Manager,
|
||||
folio.OpenMigration,
|
||||
folio.GuestsList,
|
||||
folio.StatisticsByMonth,
|
||||
|
|
97
booking.py
97
booking.py
|
@ -1525,3 +1525,100 @@ class UpdateHolder(Wizard):
|
|||
for folio in booking.lines:
|
||||
Folio.write([folio], to_folio)
|
||||
return 'end'
|
||||
|
||||
|
||||
|
||||
class ManagerStart(ModelView):
|
||||
'Manager Start'
|
||||
__name__ = 'hotel.print_manager.start'
|
||||
start_date = fields.Date('Start Date', required=True)
|
||||
end_date = fields.Date('End Date', required=True)
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
|
||||
class Manager(Wizard):
|
||||
'Manager'
|
||||
__name__ = 'hotel.print_manager'
|
||||
start = StateView('hotel.print_manager.start',
|
||||
'hotel.print_manager_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Open', 'print_', 'tryton-print', default=True),
|
||||
])
|
||||
print_ = StateReport('hotel.manager.report')
|
||||
|
||||
def do_print_(self, action):
|
||||
company = self.start.company
|
||||
data = {
|
||||
'start_date': self.start.start_date,
|
||||
'end_date': self.start.end_date,
|
||||
'company': company.id,
|
||||
}
|
||||
return action, data
|
||||
|
||||
def transition_print_(self):
|
||||
return 'end'
|
||||
|
||||
|
||||
class ManagerReport(Report):
|
||||
__name__ = 'hotel.manager.report'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
Folio = pool.get('hotel.folio')
|
||||
Room = pool.get('hotel.folio')
|
||||
rooms = Folio.search([])
|
||||
total_rooms = len(rooms)
|
||||
delta_days = (data['end_date'] - data['start_date']).days
|
||||
folios = Folio.search([
|
||||
('arrival_date', '>=', data['start_date']),
|
||||
('arrival_date', '<=', data['end_date']),
|
||||
])
|
||||
list_channels = [
|
||||
('ota', 'OTAS'),
|
||||
('direct', 'DIRECTOS'),
|
||||
('special_price', 'TARIFA ESPECIAL'),
|
||||
('courtesy', 'CORTESIA'),
|
||||
('house_use', 'USO DE CASA'),
|
||||
]
|
||||
|
||||
channels = {}
|
||||
for ch, desc in list_channels:
|
||||
channels[ch] = {
|
||||
'name': desc,
|
||||
'room_qty': [],
|
||||
'room_rate': 0,
|
||||
'num_adults': [],
|
||||
'num_children': [],
|
||||
'income': [],
|
||||
'adr': 0,
|
||||
'rev_par': 0,
|
||||
}
|
||||
|
||||
for folio in folios:
|
||||
if folio.booking.channel:
|
||||
type_ = 'ota'
|
||||
else:
|
||||
type_ = 'direct'
|
||||
channels[type_]['room_qty'].append(folio.nights_quantity)
|
||||
channels[type_]['num_adults'].append(folio.num_adults)
|
||||
channels[type_]['num_children'].append(folio.num_children)
|
||||
channels[type_]['income'].append(folio.total_amount)
|
||||
|
||||
for k, v in channels.items():
|
||||
v['room_qty'] = sum(v['room_qty'])
|
||||
v['room_rate'] = sum(v['room_qty']) / (total_rooms * delta_days)
|
||||
v['num_adults'] = sum(v['num_adults'])
|
||||
v['num_children'] = sum(v['num_children'])
|
||||
v['income'] = sum(v['income'])
|
||||
|
||||
report_context['records'] = records
|
||||
report_context['company'] = Company(data['company'])
|
||||
# report_context['startdate'] = data['date']
|
||||
return report_context
|
||||
|
|
18
booking.xml
18
booking.xml
|
@ -327,5 +327,23 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="group" ref="hotel.group_hotel"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.report" id="report_hotel_manager">
|
||||
<field name="name">Manager Report</field>
|
||||
<field name="model"></field>
|
||||
<field name="report_name">hotel.manager.report</field>
|
||||
<field name="report">hotel/manager.fods</field>
|
||||
<field name="template_extension">ods</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="print_manager_start_view_form">
|
||||
<field name="model">hotel.print_manager.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">hotel_manager_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_hotel_print_manager">
|
||||
<field name="name">Manager Report</field>
|
||||
<field name="wiz_name">hotel.print_manager</field>
|
||||
</record>
|
||||
<menuitem parent="hotel.menu_reporting" id="menu_hotel_manager"
|
||||
action="wizard_hotel_print_manager"/>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
2
dash.py
2
dash.py
|
@ -18,7 +18,7 @@ class DashApp(metaclass=PoolMeta):
|
|||
def get_selection(cls):
|
||||
options = super(DashApp, cls).get_selection()
|
||||
options.extend([
|
||||
('planner', 'Planner'),
|
||||
('hotel_planner', 'Planner'),
|
||||
])
|
||||
return options
|
||||
|
||||
|
|
18
folio.py
18
folio.py
|
@ -122,7 +122,6 @@ class Folio(ModelSQL, ModelView):
|
|||
breakfast_included = fields.Boolean('Breakfast Included', states={
|
||||
'readonly': Eval('registration_state') != 'check_in',
|
||||
})
|
||||
# paid_by_channel = fields.Boolean('Paid By Channel')
|
||||
room_amount = fields.Function(fields.Numeric('Room Amount',
|
||||
digits=(16, 2), depends=['nights_quantity', 'unit_price']
|
||||
), 'on_change_with_room_amount')
|
||||
|
@ -130,6 +129,10 @@ class Folio(ModelSQL, ModelView):
|
|||
'move', 'Stock Moves', states={'readonly': True})
|
||||
channel = fields.Function(fields.Many2One('hotel.channel', 'Channel'),
|
||||
'get_channel')
|
||||
num_children = fields.Function(fields.Integer('Num. Children'),
|
||||
'get_num_guests')
|
||||
num_adults = fields.Function(fields.Integer('Num. Adults'),
|
||||
'get_num_guests')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -155,8 +158,17 @@ class Folio(ModelSQL, ModelView):
|
|||
}
|
||||
})
|
||||
|
||||
def get_rec_name(self, name):
|
||||
name = ''
|
||||
def get_num_guests(self, name):
|
||||
res = []
|
||||
for guest in self.guests:
|
||||
if name == 'num_children' and guest.type_guest == 'child':
|
||||
res.append(1)
|
||||
elif name == 'num_adults' and guest.type_guest == 'adult':
|
||||
res.append(1)
|
||||
return sum(res)
|
||||
|
||||
def get_rec_name(self, name=None):
|
||||
if name = ''
|
||||
if self.registration_card:
|
||||
name = f'{self.registration_card}:'
|
||||
if self.main_guest:
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<newline>
|
||||
<label name="start_date"/>
|
||||
<field name="start_date"/>
|
||||
<label name="end_date"/>
|
||||
<field name="end_date"/>
|
||||
</form>
|
Loading…
Reference in New Issue