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')
pending_total = fields.Function(fields.Numeric('Pending to Pay',
digits=(16, 2)), 'get_pending_to_pay')
pax = fields.Integer('PAX', states=STATES,
help="Number of persons in house.")
pax = fields.Integer('PAX', states={
'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',
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',
select=True), 'get_count_services')
company = fields.Many2One('company.company', 'Company', required=True,
states=STATES, domain=[('id', If(In('company',
Eval('context', {})), '=', '!='), Get(Eval('context', {}),
'company', 0))])
states=STATES, domain=[
('id', If(In('company', Eval('context', {})), '=', '!='),
Get(Eval('context', {}), 'company', 0))
])
@classmethod
def __setup__(cls):
@ -304,7 +305,8 @@ class CreateDailyServicesStart(ModelView):
class CreateDailyServices(Wizard):
'Create 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', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Accept', 'accept_', 'tryton-ok', default=True),
@ -328,7 +330,7 @@ class CreateDailyServices(Wizard):
('departure_date', '>', self.start.date),
('registration_state', 'in', ['check_in', 'check_out']),
]
else: # self.kind == 'dinner':
else: # self.kind == 'dinner':
dom = [
('arrival_date', '<=', self.start.date),
('departure_date', '>', self.start.date),
@ -348,16 +350,21 @@ class CreateDailyServices(Wizard):
booking = fol.booking
if booking.plan == 'no_breakfast':
continue
if kind == 'lunch' and booking.plan in ['half_american', 'bed_breakfast']:
if kind == 'lunch' and booking.plan in [
'half_american', 'bed_breakfast']:
continue
if kind == 'dinner' and booking.plan == 'bed_breakfast':
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({
'folio': fol.id,
'service': service.id,
'room': fol.room.id,
'guest': guest.name,
'guest': guest,
'product': product.id,
'quantity': 1,
})