Add flexible report service

This commit is contained in:
oscar alvarez 2022-10-21 07:54:37 -05:00
parent b892c278ee
commit a493162fe4
3 changed files with 19 additions and 10 deletions

View file

@ -166,8 +166,10 @@ class Folio(ModelSQL, ModelView):
digits=(16, 2)), 'get_pending_to_pay') digits=(16, 2)), 'get_pending_to_pay')
pending_total = fields.Function(fields.Numeric('Pending to Pay', pending_total = fields.Function(fields.Numeric('Pending to Pay',
digits=(16, 2)), 'get_pending_to_pay') digits=(16, 2)), 'get_pending_to_pay')
pax = fields.Integer('PAX', states=STATES, pax = fields.Integer('PAX', states={
help="Number of persons in house.") 'readonly': Eval('registration_state').in_(
['check_out', 'no_show', 'cancelled']
)}, help="Number of persons in house setted manually.")
invoices = fields.Function(fields.Many2Many('account.invoice', invoices = fields.Function(fields.Many2Many('account.invoice',
None, None, 'Invoices'), 'get_invoices') None, None, 'Invoices'), 'get_invoices')

Binary file not shown.

View file

@ -60,9 +60,10 @@ class Service(Workflow, ModelSQL, ModelView):
count_services = fields.Function(fields.Integer('Count Services', count_services = fields.Function(fields.Integer('Count Services',
select=True), 'get_count_services') select=True), 'get_count_services')
company = fields.Many2One('company.company', 'Company', required=True, company = fields.Many2One('company.company', 'Company', required=True,
states=STATES, domain=[('id', If(In('company', states=STATES, domain=[
Eval('context', {})), '=', '!='), Get(Eval('context', {}), ('id', If(In('company', Eval('context', {})), '=', '!='),
'company', 0))]) Get(Eval('context', {}), 'company', 0))
])
@classmethod @classmethod
def __setup__(cls): def __setup__(cls):
@ -304,7 +305,8 @@ class CreateDailyServicesStart(ModelView):
class CreateDailyServices(Wizard): class CreateDailyServices(Wizard):
'Create Daily Services' 'Create Daily Services'
__name__ = 'hotel.daily_services' __name__ = 'hotel.daily_services'
start = StateView('hotel.daily_services.start', start = StateView(
'hotel.daily_services.start',
'hotel.create_daily_services_start_view_form', [ 'hotel.create_daily_services_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'), Button('Cancel', 'end', 'tryton-cancel'),
Button('Accept', 'accept_', 'tryton-ok', default=True), Button('Accept', 'accept_', 'tryton-ok', default=True),
@ -328,7 +330,7 @@ class CreateDailyServices(Wizard):
('departure_date', '>', self.start.date), ('departure_date', '>', self.start.date),
('registration_state', 'in', ['check_in', 'check_out']), ('registration_state', 'in', ['check_in', 'check_out']),
] ]
else: # self.kind == 'dinner': else: # self.kind == 'dinner':
dom = [ dom = [
('arrival_date', '<=', self.start.date), ('arrival_date', '<=', self.start.date),
('departure_date', '>', self.start.date), ('departure_date', '>', self.start.date),
@ -348,16 +350,21 @@ class CreateDailyServices(Wizard):
booking = fol.booking booking = fol.booking
if booking.plan == 'no_breakfast': if booking.plan == 'no_breakfast':
continue continue
if kind == 'lunch' and booking.plan in ['half_american', 'bed_breakfast']: if kind == 'lunch' and booking.plan in [
'half_american', 'bed_breakfast']:
continue continue
if kind == 'dinner' and booking.plan == 'bed_breakfast': if kind == 'dinner' and booking.plan == 'bed_breakfast':
continue continue
for guest in fol.guests: if len(fol.guests) >= fol.pax:
guests = [guest.name for guest in fol.guests]
else:
guests = [fol.main_guest.name] * fol.pax
for guest in guests:
lines_to_create.append({ lines_to_create.append({
'folio': fol.id, 'folio': fol.id,
'service': service.id, 'service': service.id,
'room': fol.room.id, 'room': fol.room.id,
'guest': guest.name, 'guest': guest,
'product': product.id, 'product': product.id,
'quantity': 1, 'quantity': 1,
}) })