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