Fix report
This commit is contained in:
parent
7e21686e21
commit
06a9844579
44
booking.py
44
booking.py
|
@ -982,6 +982,7 @@ class RoomsOccupancy(Wizard):
|
||||||
def do_print_(self, action):
|
def do_print_(self, action):
|
||||||
company = self.start.company
|
company = self.start.company
|
||||||
data = {
|
data = {
|
||||||
|
'ids': [],
|
||||||
'date': self.start.date,
|
'date': self.start.date,
|
||||||
'company': company.id,
|
'company': company.id,
|
||||||
}
|
}
|
||||||
|
@ -999,14 +1000,14 @@ class RoomsOccupancyReport(Report):
|
||||||
report_context = super().get_context(records, header, data)
|
report_context = super().get_context(records, header, data)
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Company = pool.get('company.company')
|
Company = pool.get('company.company')
|
||||||
|
User = pool.get('res.user')
|
||||||
Room = pool.get('hotel.room')
|
Room = pool.get('hotel.room')
|
||||||
Folio = pool.get('hotel.folio')
|
Folio = pool.get('hotel.folio')
|
||||||
start_date = data['date']
|
start_date = data['date']
|
||||||
all_rooms = Room.search([], order=[('code', 'ASC')])
|
all_rooms = Room.search([], order=[('code', 'ASC')])
|
||||||
operations = Folio.search([
|
folios = Folio.search([
|
||||||
('start_date', '<=', start_date),
|
('arrival_date', '<=', start_date),
|
||||||
('state', '=', 'open'),
|
('registration_state', '=', 'check_in'),
|
||||||
('kind', '=', 'occupancy'),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
def _get_default_room(r):
|
def _get_default_room(r):
|
||||||
|
@ -1018,43 +1019,42 @@ class RoomsOccupancyReport(Report):
|
||||||
'arrival': None,
|
'arrival': None,
|
||||||
'departure': None,
|
'departure': None,
|
||||||
'booking': None,
|
'booking': None,
|
||||||
'reference': None,
|
'registration_card': None,
|
||||||
'amount': None,
|
'amount': 0,
|
||||||
'balance': None,
|
'registration_state': None,
|
||||||
'state': None,
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
rooms_map = {room.id: _get_default_room(room) for room in all_rooms}
|
rooms_map = {room.id: _get_default_room(room) for room in all_rooms}
|
||||||
occupancy_rooms = 0
|
occupancy_rooms = 0
|
||||||
for op in operations:
|
for op in folios:
|
||||||
name = op.main_guest.name if op.main_guest else op.party.name
|
|
||||||
rooms_map[op.room.id].update({
|
rooms_map[op.room.id].update({
|
||||||
'guest': name,
|
'guest': op.main_guest.name,
|
||||||
'num_guest': len(op.guests),
|
'num_guest': len(op.guests),
|
||||||
'party': op.party.name,
|
'party': op.booking.party.name if op.booking.party else '',
|
||||||
'arrival': op.start_date,
|
'arrival': op.arrival_date,
|
||||||
'departure': op.end_date,
|
'departure': op.departure_date,
|
||||||
'reference': op.reference,
|
'registration_card': op.registration_card,
|
||||||
'amount': op.total_amount,
|
'amount': op.total_amount,
|
||||||
'balance': op.total_amount_today,
|
'booking': op.booking.number,
|
||||||
'state': op.state,
|
'registration_state': op.registration_state,
|
||||||
})
|
})
|
||||||
occupancy_rooms += 1
|
occupancy_rooms += 1
|
||||||
|
|
||||||
if all_rooms:
|
if all_rooms:
|
||||||
occupancy_rate = (float(len(operations)) / len(all_rooms)) * 100
|
occupancy_rate = (float(len(folios)) / len(all_rooms)) * 100
|
||||||
else:
|
else:
|
||||||
occupancy_rate = 0
|
occupancy_rate = 0
|
||||||
|
|
||||||
user = Pool().get('res.user')(Transaction().user)
|
# recs = rooms_map.values()
|
||||||
recs = rooms_map.values()
|
records = rooms_map.values()
|
||||||
report_context['records'] = rooms_map
|
print('XXXXX.......', rooms_map)
|
||||||
|
report_context['records'] = rooms_map.values()
|
||||||
report_context['occupancy_rate'] = occupancy_rate
|
report_context['occupancy_rate'] = occupancy_rate
|
||||||
report_context['occupancy_rooms'] = occupancy_rooms
|
report_context['occupancy_rooms'] = occupancy_rooms
|
||||||
report_context['company'] = Company(data['company']).party.name
|
report_context['company'] = Company(data['company']).party.name
|
||||||
report_context['date'] = data['date']
|
report_context['date'] = data['date']
|
||||||
report_context['user'] = user.rec_name
|
report_context['user'] = User(Transaction().user).rec_name
|
||||||
return report_context
|
return report_context
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue